1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Print string with html tags

Discussion in 'XenForo Development Discussions' started by Ubiquity Lab, May 18, 2016.

  1. Ubiquity Lab

    Ubiquity Lab New Member

    In my template I need to print a string with some html tags in it.

    Let's say I have:

    $my_string = "This is my string with a <a href="https://xenforo.com">link</a>"

    If I use the simple {$my_string} the html tags won't be parsed and will be displayed as string.

    I didn't find any documentation about how to parse this kind of string. Any suggestions?
  2. Chris D

    Chris D XenForo Developer Staff Member

    {xen:raw $my_string}
    That should do it :)
    Ubiquity Lab likes this.
  3. Ubiquity Lab

    Ubiquity Lab New Member

    Thank you @Chris D ! That's exactly what I was looking for.
    Can you tell me where is the reference of this xen directive, if there's any?
    I wonder how come I didn't find it by myself o_O
  4. Chris D

    Chris D XenForo Developer Staff Member

    There's no documentation, as such, but it is used in places in the existing templates.

    It should be used sparingly. It essentially prevents the value from being escaped which is usually preferable to avoid being open to XSS vulnerabilities.

    In terms of seeing what else there is, you could search templates for {xen: to see what else there is. There's some more prevalent than others, such as {xen:phrase and {xen:link.
    Ubiquity Lab likes this.

Share This Page