groue / GRMustache.swift

Flexible Mustache templates for Swift
http://mustache.github.com/
MIT License
597 stars 155 forks source link

Line breaks #38

Open yonaskolb opened 7 years ago

yonaskolb commented 7 years ago

Hey, great library! Would it be possible to ignore line breaks in a template when a line only contains a single {{# tag? This would mean you could write:

enum {{enumName}} { 
    {{#enums}}
    case {{name}} = "{{value}}"
    {{/enums}}
}

instead of

enum {{enumName}} { {{#enums}}
    case {{name}} = "{{value}}"{{/enums}}
}

where you would want each case of that enum to be on a seperate line with no empty lines in between.

It greatly cleans up mustache template files, especially if you have many nested loops

acecilia commented 4 years ago

@groue I would very much appreciate you feedback on this :)

groue commented 4 years ago

Well, the source code is here, ready to be modified. Make sure you don't change the runtime just for your convenience, because what's good for you may be a pain for another user. Instead, look at the mustache standard, and plan well your modifications. Ask @fumito-ito if he plans to merge them in the repository before you open a pull request. Happy coding!

acecilia commented 4 years ago

@groue thanks for your answer.

So far I have solved this issue by using the technique explained in the following comment https://github.com/groue/GRMustache/issues/46#issuecomment-19498046