Examples for Sourcerer
Here are some simple examples of how to place code with Sourcerer.
HTML tags
Code
{source}<span style="color:red">This text should be red!</span>{/source}
Result
This text should be red!
HTML tags (with double square brackets)
If your editor has problems saving tags entered in the WYSIWYG view, and strips these upon saving, then you can use the double bracket syntax for tags.
So [[tag]]
instead of <tag>
.
Code
{source}[[span style="color:red"]]This text should be red![[/span]]{/source}
Result
This text should be red!
JavaScript
Code
{source} <script type="text/javascript"> document.write('This text is placed through <strong>JavaScript</strong>!'); </script> {/source}
Result
PHP
Code
{source} <?php echo 'This text is placed through <strong>PHP</strong>!'; ?> {/source}
Result
This text is placed through PHP!
Combined (HTML, JavaScript and PHP)
Code
{source} <span style="color:red">This text should be red!</span> <br /> <script type="text/javascript"> document.write('This text is placed through <strong>JavaScript</strong>!'); </script> <?php echo '<p>'; echo 'This text is placed through <strong>PHP</strong>!'; echo '</p>'; ?> {/source}
Result
This text should be red!
This text is placed through PHP!