Don't write blank lines for lines with only {{ }} tags in them #357

Closed
EntitySpaces opened this Issue Nov 6, 2012 · 1 comment

Projects

None yet

2 participants

@EntitySpaces

For instance:

If my template is such (which reads very nicely). The {{NotLast}} tags are our extensions, ignore them

 SELECT 
 {{#each Columns}}
   [{{Name}}]{{NotLast ","}}
 {{/each}}
 FROM 
   [{{Schema}}].[{{Name}}]
 WHERE
 {{#each PrimaryKeys}}
   [{{Name}}] = @{{Alias}}{{NotLast " AND "}}
 {{/each}}

The output looks like this (which isn't great)

 SELECT 

      [EmployeeID],

      [LastName],

      [FirstName],

      [Supervisor],

      [Age]

 FROM 
  [dbo].[Employee]
 WHERE

     [EmployeeID] = @EmployeeID

So, I end up having to write my template like this:

    SELECT{{#each Columns}}
        [{{Name}}]{{NotLast ","}}{{/each}}
    FROM 
        [{{Schema}}].[{{Name}}]
    WHERE{{#each PrimaryKeys}}
        [{{Name}}] = @{{Alias}}{{NotLast " AND "}}{{/each}}

Which doesn't read a nice as the original to get my output to look this:

 SELECT 
       [EmployeeID],
       [LastName],
       [FirstName],
       [Supervisor],
       [Age]
  FROM 
       [dbo].[Employee]
 WHERE
       [EmployeeID] = @EmployeeID

It would be totally awesome if handlebars realized a line was nothing but a tag such as {{each}} and didn't write out a blank line, that is, the concept of a tag with no output so our templates could be written in a very easy to understand format. The above is just a very simple sample, it gets very ugly once we start throwing in {{If}} tags and many others ...

@kpdecker
Collaborator

Closing this issue so we can consolidate whitespace handling issues on #336

@kpdecker kpdecker closed this Apr 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment