ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Closing a snippet?

March 05, 2011 6:01pm

Subscribe [4]
  • #1 / Mar 05, 2011 6:01pm

    scruffpuff

    17 posts

    I have a snippet called ‘encodeHTMLchars’ that looks like this:

    {exp:tagstripper:tagsToStrip escapeHTMLchars='true'}

    This snippet needs to wrap some content:

    {encodeHTMLchars}something & something{/encodeHTMLchars}

    However I can’t just close encodeHtmlchars like that. Instead I have to define another snippet with the closing tag in it.

    Is there a way around this or is that pretty much the standard?

    EE2 v2.1.3

  • #2 / Mar 05, 2011 9:08pm

    Will Bolton

    30 posts

    Surely you don’t need to use a snippet in this case. Just wrap your content in the tagStripper plugin’s tags in your template:

    {exp:tagstripper:tagsToStrip escapeHTMLchars='true'}something & something{/exp:tagstripper:stripAllTags}
  • #3 / Mar 05, 2011 10:08pm

    Mark Bowen

    12637 posts

    I’m with Will here. Would love to know exactly what you’re trying to do here because doing something like that in a template would be exactly the same as if you had just written it all in the one template in the first place surely?

    Best wishes,

    Mark

  • #4 / Mar 06, 2011 7:38pm

    scruffpuff

    17 posts

    Sure,

    So basically I’ve inherited a site which is powered by XML. The previous developer thought it wise to use XML attributes for almost every single aspect :\ As such, my template has a lot of attributes that all need to be encoded. The only reason I was using a snippet was to condense the amount of code on the page so that:

    {exp:tagstripper:tagsToStrip escapeHTMLchars='true'}
    could be shortened to
    {encodeHTMLchars}

    because it’s going to appear quite a few times.

  • #5 / Mar 06, 2011 8:21pm

    Will Bolton

    30 posts

    Ah, OK. I wondered whether there was a specific reason you were trying to do things that way, rather than it just being the case that you were a bit confused!

    In that case, I’m pretty sure the answer is that you will need two snippets - one to open, and one to close the tagStripper tags.

  • #6 / Mar 06, 2011 9:11pm

    scruffpuff

    17 posts

    cool thanks man 😊

  • #7 / Mar 07, 2011 9:33am

    Sue Crocker

    26054 posts

    scruffpuff - sounds like you’re all set. Thanks for the assist, Will and Mark.

    Feel free to start a new thread if you have any more questions.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases