RejectedSoftware Forums

Sign up

D indent vs Diet indent

Is there some way to do this:

- if(foo)
  .class.true
- else
  .class.false
//- close D code indent but keep diet indent
    - bar();
    - baz();

Instead of this:

- if(foo)
  .class.true
    - bar();
    - baz();
- else
  .class.false
    - bar();
    - baz();

Re: D indent vs Diet indent

Am 23.04.2015 um 18:42 schrieb Lemonfiend:

Is there some way to do this:

- if(foo)
   .class.true
- else
   .class.false
//- close D code indent but keep diet indent
     - bar();
     - baz();

Instead of this:

- if(foo)
   .class.true
     - bar();
     - baz();
- else
   .class.false
     - bar();
     - baz();

Not directly, but you could avoid redundancies like this:

- string cls = foo ? "true" : "false";
.class(class=cls)
   - bar();
   - baz();

Or move the nested contents to a separate function (can contain HTML
markup, too):

- function content()
   - bar();
   - baz();
- if (foo)
   .class.true
     - content();
- else
   .class.false
     - content();

Re: D indent vs Diet indent

On Fri, 24 Apr 2015 19:23:31 +0200, Sönke Ludwig wrote:

Am 23.04.2015 um 18:42 schrieb Lemonfiend:

Is there some way to do this:

- if(foo)
   .class.true
- else
   .class.false
//- close D code indent but keep diet indent
     - bar();
     - baz();

Instead of this:

- if(foo)
   .class.true
     - bar();
     - baz();
- else
   .class.false
     - bar();
     - baz();

Not directly, but you could avoid redundancies like this:

- string cls = foo ? "true" : "false";
.class(class=cls)
   - bar();
   - baz();

Or move the nested contents to a separate function (can contain HTML
markup, too):

- function content()
   - bar();
   - baz();
- if (foo)
   .class.true
     - content();
- else
   .class.false
     - content();

I see!

Re: D indent vs Diet indent

Small correction:

  • function content()

should be - void content()