-
Notifications
You must be signed in to change notification settings - Fork 71
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
Feature Request: Variable Defaults #64
Comments
Sure. Check the template delegate guide, linked from the README. It covers exactly this use case. |
Maybe I'm missing something but I wasn't able to find it. Are you referring to the mustache spec README.md? |
Nope. Sorry I'm on a mobile phone and copy pasting a link is not so easy : look for "tag delegate" in the GRMustache home page on github. Follow the link. There is the solution to your issue. Tell me if it works as I expect. |
Oops, sorry, wrong repo. My mistake. Mustache has no such feature. Some implementations do, such as GRMustache. I advise you to check with your current Mustache implementation. |
Unfortunately, the templates I write need to work under multiple implementations, so I can't rely on implementation-specific code. |
Yes. But you can open issues in each of these implementation repositories. Before making the exact same suggestion, please open your eyes, and see that your suggestion:
Some implementations provide with the feature you are looking for in a much more general way. Please, please, please, don't suggest JS/PHP implementations to implement your |
I understand your concerns. If mustache doesn't currently parse literal values this would indeed be a much larger undertaking than simply adding a new operator. The |
Yes @spudly, I agree filters could do that as well. In GRMustache, you have two ways to provide default values:
This issue is typical of an use case that does not deserve a specific solution. It needs (#41), or has (GRMustache delegate and filters) more general mechanisms that include a solution for it. |
Closing in favor of #41. |
Right now if you tell mustache to output a variable, it defaults to empty string if the variable has no value. I'd like to be able to specify a default string to output in this case. For example:
Data:
With the current spec, I would have to write this:
If some sort of default syntax were added, I could write this instead:
The text was updated successfully, but these errors were encountered: