-
Notifications
You must be signed in to change notification settings - Fork 340
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
If statements inside an element attribute #77
Comments
I was able to make this work using a view helper. Should I be able to use that syntax however inside an attribute? |
Using {{if}} or {{each}} within attribute markup does not currently work by default, if JsViews is loaded, because JsViews sets a flag for JsRender: Otherwise you can do:
Or again, you can use data binding, along the lines of:
I think some of this will change when we reach beta for JsViews, and this problem should no longer arise... |
With the latest update, you can set var html = $("#myTemplate").render(data, {link: false}); or var html = $.render.myTemplate(data, {link: false}); But if you are using JsViews data within your template, you probably don't want to switch off the linking for the whole template. In that case, you can instead set <div title="{{:first}} {{if preferred_first != first link=false}}({{:preferred_first}}){{/end}} {{:last}}"> You can even use one or more {{else}} tags, as long as you put link=false on each of them: <div {{if test link=false}}id="yay"{{else test2 link=false}}class="special"{{else link=false}}id="nay"{{/if}}> Closing, since this scenario is now supported. |
Data elements render inside an attribute of an element in a template, but the conditional if statement does not seem to work (see title attribute of div element below):
When it renders I see:
<div class="runtemplatex" title="Hudson <!--tmpl() _5--><!--/tmpl--> Moore ">
<!--tmpl() _10-->
<img src="filesystem:http://localhost:8082/persistent/images/hpm6-176790.jpg">
<!--/tmpl-->
</div>
The injected annotations seem to be the problem. Any way to stop those?
Thanks,
Joseph Conder
The text was updated successfully, but these errors were encountered: