This project has moved and is read-only. For the latest updates, please go here.

Using the excerpt function...

Oct 22, 2010 at 4:33 PM

I am using the $post.Excerpt function on the post feed on the index.view template and as a standard function this strips out all html and puts the first N characters into a p tag of it own.

Is there a parameter to stop it striping out the HTML?

We are using HTML bullet points as the main body of our posts and want this markup to be used on the excerpt, otherwise it combines the bullet point and they dont read right.

Can anyone help?

Oct 22, 2010 at 4:58 PM

If you have an Extended body on the post the $post.Excerpt will use the body of the post including the HTML.

Also, look into the CustomExcept -- I can't remember if it strips the HTML or not.

Oct 22, 2010 at 5:09 PM
madkidd wrote:

If you have an Extended body on the post the $post.Excerpt will use the body of the post including the HTML.

Also, look into the CustomExcept -- I can't remember if it strips the HTML or not.

Actually, according to the current code, this is incorrect. The code ALWAYS strips the HTML (as does CustomExcerpt). Reading the comments, it looks like it is supposed to leave the post body if it is shorter than the excerpt length (regardless of the existence of the extended body actually), but it doesn't do it that way. All the existence of an extended body does is append the ellipsis.

Oct 25, 2010 at 9:13 AM

OK thats cool feedback guys, thanks for you time. I take it there is no way to overwrite that function anywhere?

Oct 25, 2010 at 3:37 PM

Nope, don't think so. You're best bet is to create a custom Chalk extension which will give you complete control. You can then do something like $myChalk.Excerpt($post.Body)

If you want to post it as a feature request, we can look at adding a Excerpt to the post that will keep the HTML. Though, don't expect a quick turn-around on anything posted as a feature request. :-)

Oct 25, 2010 at 3:49 PM

You CAN also just modify your copy of the source. It is an open-source project after all. Or, on the same vein, you can modify your copy of the source AND submit it as a patch.

Oct 27, 2010 at 6:08 PM

I worked on some updates to the Excerpt function a while back. I remember there was one way to get the excerpt with HTML included, I think if the total length of the post was shorter than the except you wanted to display, but we took this out for consistency so they html is never included.

The problem is if you include html, it likely you'll chop an html tag in half and break your site. Its not worth the risk. You might have an unclosed paragraph tag or bold tag... maybe something worse.