What are {literal} tags?

A common issue Pligg users come across when trying to add CSS or JavaScript to a template file is that it will sometimes result in a broken (blank white) site. What causes this is the use of {curly} brackets in the code, which confuses Pligg’s template engine. Pligg uses curly brackets as opening and closing delimiters, which basically means that curly brackets are Pligg’s way of figuring out when you are trying to use template variables or perform other template logic. Curly brackets are associated with JavaScript and CSS coding, which means that you will need to take an extra step when embedding these types of code in your template files.Below is an example of Google’s Analytics tracking code, which embeds a bit of JavaScript into your site to track visitors. If you look at the code, you will notice that it uses curly brackets to define a JavaScript function. Your website won’t know how to interpret the code within those curly brackets and as a result it may break the site. The workaround for this is to wrap the entire JavaScript section with {literal} tags. One {literal} at the start of the JavaScript, and a {/literal} at the bottom of the code. This tells Pligg’s template system to ignore processing the content contained within the {literal} tags, so that it will display the content as-is.
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

Cascading style sheet (CSS) code also use curly brackets to define element properties, so you will need to apply the same technique and wrap it with {literal} / {/literal} tags.
<style type="text/css">
Share this post

2 thoughts on “What are {literal} tags?

Comments are closed.