Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
EntitySpaces opened this issue Nov 6, 2012 · 1 comment
Closed
Labels

Comments

@EntitySpaces
Copy link

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
Copy link
Collaborator

kpdecker commented Apr 7, 2013

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

@kpdecker kpdecker closed this as completed Apr 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants