Meteor - TRIPLE template tag not allowed in HTML attribute error

I got an error while trying to start an existing meteor project.

$meteor

=> Started proxy.
=> Started MongoDB.
=> Errors prevented startup:

While building the application:
client/coinmx.html:169: TRIPLE template tag is not allowed in an HTML attribute
...title="Totals:  {{{get...
                        ^
+4
source share
3 answers

In Meteor 0.8, you can return a Javascript object that is directly displayed in HTML attributes compared to earlier versions where you needed to make it yourself.

Old version:

<input name={{name}} title={{title}}>

helpers:

Template.foo.name = "fooName";
Template.foo.title = "fooTitle";

A new version:

<input {{attributes}}>

helpers:

Template.foo.attributes = {
  name: "fooName",
  title: "fooTitle"
};

All of them can be functions, reactive, etc. Since the object is rendered directly in the attributes, you do not need SafeStringsome manually displayed content, as before. This is the recommended way if you need to render HTML attributes.

. , :

https://github.com/meteor/meteor/wiki/Using-Blaze#conditional-attributes-with-no-value-eg-checked-selected

+3

: {{{something}}} HTML, {{something}}. , something ( , ), , , , new Handlebars.SafeString("result") , "result". , , , , , HTML.

+1

Hugo , - 0.8 . , , , .

If you may have had {{{resolve}}} in your template, you should:

<template name='thing'>
  <ol>
    {{#each all}}
      {{resolve}}
    {{/each}}
  </ol>
<template>

Then, in the helper code, Spacebars.SafeString is used, which Blaze prefers:

Template.thing.helpers({
    all: function () {
        return Things.find();
    },

    resolve: function () {
        var result = "<li>";
        for (var i = 0; i < this.arrayOfClassNames.length; ++i)
            result += <'div class='" + this.arrayOfClassNames[i] + "'></div>";
        result += "</li>";
        return new Spacebars.SafeString(result);
    }
});

The key here is to return the “new Spacebars.SafeString (result)” to wrap your HTML (which should be well-formed).

+1
source

Source: https://habr.com/ru/post/1535322/


All Articles