Substring splits the contents in side it into a smaller portion. This is often used when previewing content, like first few lines of a news item.
You can keep only a certain amount of characters from the beginning or the end, or until certain character or word is found.
Attributes
Examples
Previewing news items
Here's a common use for sub string, where we show first few lines of news items in the front page of the site.<h3>Latest news</h3>
<b:get from="news" name="n" amount="2" orderby="metadata.created" direction="desc">
<div class="newsitem">
<h4><b:n.topic/></h4>
<p>
<b:format.substring length="24" suffix="..."><b:n.content/></b:format.substring>
<a href="<b:n.metadata.url/>">Read more</a>
</p>
</div>
</b:get>
HTML source output
<h3>Latest news</h3>
<div class="newsitem">
<h4>News 1</h4>
<p>
The quick brown fox jump...
<a href="/news/news-1">Read more</a>
</p>
</div>
<div class="newsitem">
<h4>News 2</h4>
<p>
The quick brown fox jump...
<a href="/news/news-2">Read more</a>
</p>
</div>
Using attributes
Here's how different attributes behave. Let's assign a sentence in <b:value.story/> and start splitting that.
<b:value.story set="The quick brown fox jumps over the lazy dog"/> <b:format.substring length="14"><b:value.story/></b:format.substring> Outputs: The quick brow <b:format.substring start="14"><b:value.story/></b:format.substring> Outputs: n fox jumps over the lazy dog <b:format.substring end="14"><b:value.story/></b:format.substring> Outputs: The quick brow <b:format.substring start="16" length="10"><b:value.story/></b:format.substring> Outputs: fox jumps <b:format.substring start="-5"><b:value.story/></b:format.substring> Outputs: y dog <b:format.substring end="-5"><b:value.story/></b:format.substring> Outputs: The quick brown fox jumps over the laz <b:format.substring startbefore="quick"><b:value.story/></b:format.substring> Outputs: quick brown fox jumps over the lazy dog <b:format.substring startafter="quick"><b:value.story/></b:format.substring> Outputs: brown fox jumps over the lazy dog <b:format.substring endbefore="lazy"><b:value.story/></b:format.substring> Outputs: The quick brown fox jumps over the <b:format.substring endafter="lazy"><b:value.story/></b:format.substring> Outputs: The quick brown fox jumps over the lazy <b:format.substring startbefore="fox" endbefore="over"><b:value.story/></b:format.substring> Outputs: fox jumps <b:format.substring startafter="quick" prefix="The sneaky"><b:value.story/></b:format.substring> Outputs: The sneaky brown fox jumps over the lazy dog

