Meteor 0.8.0: When creating the application: Unexpected closing template tag

I have this section in my template, the tag for unexpectedly closing the template is {{/ if}}.

{{#if selected}} <div class="Answer--selected"> {{else}} <div class="Answer"> {{/if}} <i class="fa"></i> {{title}} </div> 

What is wrong with this code?

+6
source share
3 answers

I believe this will work if you just want to change the class name based on the condition.

 <div class="{{#if selected}}Answer--selected{{else}}Answer{{/if}}"> <i class="fa"></i> {{title}} </div> 

Until you break the begin / end tag with your helper, you should be fine.

Steve

+6
source

Meteor Devwork answered my question. One of the main changes in Meteor 0.8.0 is the new Blaze template system, which makes your templates a completely new way. Instead of re-generating the entire HTML fragment every time the template renders itself, Blaze finds only the DOM nodes that need to be updated and makes the minimum possible changes. This means that you are no longer allowed to have private HTML tags inside block helpers.

So, the corrected code is as follows:

 {{#if selected}} <div class="Answer--selected"> <i class="fa"></i> {{title}} </div> {{else}} <div class="Answer"> <i class="fa"></i> {{title}} </div> {{/if}} 

NTN

+7
source

Meteor 0.8.0 has a completely rewritten template engine. Called by Blaze.

Take a look at the docs.meteor.com docs and, in particular, the wiki page when using blaze. https://github.com/meteor/meteor/wiki/Using-Blaze

0
source

All Articles