Q:

Symfony2 removing part of a text with css when rendering text with twig

I am using an already made template and now I am having problems when I am trying to display a set of products with descriptions...
All of the products have different descriptions and If one products has more text, its thumbnail is larger, thus it makes the product list look terrible..
This is the thumbnail:
<ul class="thumbnails">
   {% for item in pagination %}
      <li class="span3">
          <div class="thumbnail">
              <div class="caption">
                <p>
                    <span>{{ entry.shortDescription|raw }}</span>
                </p>
              </div>
          </div>
        </li>
  {% endfor %}
</ul>

Now how to make this work, for example I want to add only the first 200 letters form all of the products... Is that possible to do from a twig?

A:

Yes it is, but I would definitely do it by using a twig filter, which would truncate the description string. You have a set of twig extensions you can add to your application: http://twig.sensiolabs.org/doc/extensions/index.html . Specifically, look at the "Text" extension and it's truncate filter

