[eluser]pedro_fp_simoes[/eluser]
Hi,
I have modified the original CI Template parser to suit my needs, the changes are:
1. Fixed error when the parser get's an stdClass;
2. Added the possibility to have the same iteration in 2 different places;
3. Added simple conditional branches;
4. Fixed compatibility with views, so you can use templates where was a view;
How to use:
The same way you use the original parser, but:
1. Must place the file Parser2.php in application/libraries;
2. Must load with the name parser2 instead of parser;
3. You can place the same iteration in 2 different places;
4. You can use simple conditionals,
{boolean_var}string{/boolean_var} or
{!boolean_var}string{/boolean_var}
The purpose was to maintain the same structure of the original and add some small but essencial features.
Code:
<html>
<head>
<title>{blog_title}</title>
</head>
<body>
{show_heading}
<h3>{blog_heading}</h3>
{/show_heading}
{blog_entries}
<h5>{title}</h5>
{has_excerpt}
<p>{excerpt}</p>
<a href="{site_url}/contents/{id}">Read more ...</a>
{/has_excerpt}{!has_excerpt}
<p>{body}</p>
{/has_excerpt}
{/blog_entries}
</body>
</html>
for now I have a problem defining the else part with regex, the workaround is to use 2 separate if's, like this {/has_excerpt}{!has_excerpt}