Alternative double bracket syntax

Some editors (i.e. TinyMCE) will strip HTML style tags when you enter them in the WYSIWYG view. For that reason you can also use double square brackets for the HTML style tags. So if your tags get stripped, use the double bracket syntax.

For instance, instead of doing this:

{source}<strong>Text</strong>{/source}

You can also do this:

{source}[[strong]]Text[[/strong]]{/source}

Using HTML entities

When you want to use html entities in your code, you will notice that most editors will convert them to actual characters when saving.

You can prevent that from happening by adding an underscore (_) after & to escape it, like:

{source}Sch&_ouml;n{/source}

Not using a WYSIWYG editor?

Sourcerer is designed to be used with a WYSIWYG editor. It will strip all tags entered in the HTML/Code view of the content, to prevent styling from messing with the code.

When you do not use a WYSIWYG editor (or the field where you want to enter the code has no editor), practically all code would be stripped, which you don't want of course.

To prevent Sourcerer from stripping the HTML code, you can add a raw="true" attribute in the {source} tag, like:

{source raw="true"}<p>Code in an <strong>HTML</strong> editor</p>{/source}

Strip surrounding HTML tags

By default Sourcerer will output your code right inside your content where you placed your {source} tags.

However, most editors treat new lines as paragraphs, meaning that the {source} tags will get surrounded by <p> tags.

If you - for instance - include a file through Sourcerer that outputs a table, and your {source} tags are surrounded by <p> tags, then you would get a table inside a paragraph, which you don't want of course.

To make Sourcerer remove the surrounding paragraph tags (or span tags), you can switch on the Strip surrounding tags option in the Sourcerer system plugin settings.

Or you can individually override this setting in the {source} tag by adding a trim="..." attribute with either a true (on) or false (off) value:

<p>{source trim="true"}Surrounding paragraph will be stripped from the output{/source}</p>

For more troubleshooting tips in case something doesn't work as expected, check out the Frequently Asked Questions page.