Answers.Body: <p>Check out the <a href="http://buildwithcraft.com/docs/plugins/hooks-reference#addTwigExtension" rel="nofollow">Craft Plugin documentation on adding a Twig extension with a plugin</a>. There is no clean way to add extensions manually without a plugin, as the changes might be overridden with Craft updates.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-01T17:41:36.287Z
Answers.Text: Can you expand on this answer? It points in a direction but doesn't offer anything concrete in terms of the question addressed. There are many guides on adding Twig extensions, but none that address specifically importing the Twig Extensions lib, which is different from importing a hand-crafted Twig plugin, which is rather straightforward in of itself.
Answers.UserDisplayName: Gavin
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-01T02:01:00.423Z
Answers.LastActivityDate: 2015-02-01T02:01:00.423Z
Answers.UserDisplayName: Aaron Berkowitz
Body: <p>I'd like to add the Text extension: </p>
  
  <p><a href="http://twig.sensiolabs.org/doc/extensions/index.html#extensions-install" rel="nofollow">http://twig.sensiolabs.org/doc/extensions/index.html#extensions-install</a></p>
  
  <p>Which seems very useful because of the truncate functionality. Any idea on how to accomplish this? </p>
  
  <p>(this could've been installed by default)</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-20T14:02:26.453Z
Comments.Text: What's the advantage of the `truncate` filter? What does it do that you can't achieve with [`slice`](http://twig.sensiolabs.org/doc/filters/slice.html)?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-20T14:08:43.780Z
Comments.Text: Did you see this question: ["Best method of text truncating"](http://craftcms.stackexchange.com/q/661/125)?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-12-01T17:42:25.147Z
Comments.Text: I appreciate these comments but neither of them address the question asked.
  
  1) Slicing a string is a very simple operation. Truncating text when markup is present, without destroying the underlying DOM, is a very different operation and there are, as of yet, no perfect solutions for this. The major alternative that works in many cases has issues, as outlined below.
  
  2) The answer to the linked question of "Best method of text truncating" is the Hacksaw plugin. Hacksaw is not a perfect solution and has bugs in the way it truncates with markup present, specifically around char count control
Comments.UserDisplayName: Gavin
Tags: <templating>
Title: How to get the Twig Text extension loaded
ThreadText: # How to get the Twig Text extension loaded
  
  (Asked by: username_0 on 2015-01-20)
  
  I'd like to add the Text extension:
  
  <http://twig.sensiolabs.org/doc/extensions/index.html#extensions-install>
  
  Which seems very useful because of the truncate functionality. Any idea on how to accomplish this?
  
  (this could've been installed by default)
  
  **Tags:** templating
  
  > **Comments:**
  > **username_1**: What's the advantage of the `truncate` filter? What does it do that you can't achieve with [`slice`](http://twig.sensiolabs.org/doc/filters/slice.html)?  
  > **username_1**: Did you see this question: ["Best method of text truncating"](http://craftcms.stackexchange.com/q/661/125)?  
  > **username_2**: I appreciate these comments but neither of them address the question asked.  1) Slicing a string is a very simple operation. Truncating text when markup is present, without destroying the underlying DOM, is a very different operation and there are, as of yet, no perfect solutions for this. The major alternative that works in many cases has issues, as outlined below.  2) The answer to the linked question of "Best method of text truncating" is the Hacksaw plugin. Hacksaw is not a perfect solution and has bugs in the way it truncates with markup present, specifically around char count control  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2015-02-01. Score: 2
  
  Check out the [Craft Plugin documentation on adding a Twig extension with a plugin](http://buildwithcraft.com/docs/plugins/hooks-reference#addTwigExtension). There is no clean way to add extensions manually without a plugin, as the changes might be overridden with Craft updates.
  
  > **Comments:**
  > **username_2**: Can you expand on this answer? It points in a direction but doesn't offer anything concrete in terms of the question addressed. There are many guides on adding Twig extensions, but none that address specifically importing the Twig Extensions lib, which is different from importing a hand-crafted Twig plugin, which is rather straightforward in of itself.  
  
  ---
  
  