title: Handlebars - substring
body: <p>I am new to <a href="http://handlebarsjs.com/" rel="noreferrer">Handlebars</a> templating system and this is my first project I am working on with Handlebars. I have created simple template:</p>
  
  <pre><code>&lt;script id="article_list_template" type="text/x-handlebars-template"&gt;
      {{#each this}}
      &lt;div class='article'&gt;
      &lt;a href='article.php?id={{id_news}}' data-article_id='{{id_news}}'&gt;
          &lt;h1&gt;{{title}}&lt;/h1&gt;
      &lt;/a&gt;
          &lt;p&gt; {{{content}}} &lt;/p&gt;
      &lt;div style='clear: both;'&gt; &lt;/div&gt;
      &lt;/div&gt;
      {{/each}}
  &lt;/script&gt;
  </code></pre>
  
  <p>Returned <code>content</code> is very long. I want it to be shorter, e.g. 150 chars. I was trying to use JavaScript <code>substring()</code> method as follows:</p>
  
  <p><code>&lt;p&gt; {{{content.substring(0,150)}}} &lt;/p&gt;</code></p>
  
  <p>But it obviously did not work. Could you give me some tips how to deal with that problem. Thanks</p>
  
  <p>Edit:
  Okay, problem solved:
  I have done it in PHP, so that returned content has now proper length:</p>
  
  <pre><code>foreach ($articles as $a) {
      $a-&gt;content = cut_text( $a-&gt;content, 30);
  }
  </code></pre>