Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
@Umbraco.Truncate("<p><strong> this is my really really really really really really short blog post</strong></p>",10,false)
results in
<p><strong this is</strong></p></div>
Notice the open strong tag is broken. Has anyone else noticed this? About to just roll my own.
Hi Bob,
I'm pretty sure there is method in here that would do the job properly.
Jeavon
Another approach is to leverage Tidy... I found you have to help a little for when the trunacte causes a break in a tag, but quite straight forward..
Sorry could only find xslt example.. but should apply in razor or usercontrol too..
<!-- we may be splitting mid tag!! -->
<xsl:variable name="xmlFragment">
<xsl:value-of select="substring(umbraco.library:GetXmlNodeById($nodeId)/abstract, 1, $abstractLength)" disable-output-escaping="yes"/>
</xsl:variable>
<!-- help tidy out by removing any unclosed tag at the end of the string not so hot at this itself -->
<xsl:variable name="regExp"><xsl:text disable-output-escaping="yes">[\s\S]*>[^<]*</xsl:text></xsl:variable>
<xsl:value-of disable-output-escaping="yes" select="umbraco.library:Tidy(Exslt.ExsltRegularExpressions:match($xmlFragment, $regExp), false)" />
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Bad HTML generated by Umbraco.Truncate()?
@Umbraco.Truncate("<p><strong> this is my really really really really really really short blog post</strong></p>",10,false)
results in
<p><strong this is</strong></p></div>
Notice the open strong tag is broken. Has anyone else noticed this? About to just roll my own.
Hi Bob,
I'm pretty sure there is method in here that would do the job properly.
Jeavon
Another approach is to leverage Tidy... I found you have to help a little for when the trunacte causes a break in a tag, but quite straight forward..
Sorry could only find xslt example.. but should apply in razor or usercontrol too..
is working on a reply...