Skip to content
CodeIgniter 3 Parser Library extension
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
libraries
README.md
composer.json

README.md

CodeIgniter Parser

CI Parser Library extension (empty tags replacement, extended loops, conditional IF and SWITCH structures, CI Helper calls)

Initial Note

To see how to load, initialize and use standard methods of the CI Parser Library, see Template Parser Class Documentation


## Installation by Composer #### Option 1 : Run composer ```shell composer require gccloud/parser ``` #### Option 2 : or edit /composer.json ```json { "require": { "gccloud/parser": "1.0.*" } } ``` #### And then run composer update ```shell composer update ```
## Basic Changes - While parsing a view, all tags found that does not match any data variable will be replaced with an empty string - The Parser will automatically parse any variable loaded in CI via the Loader Class
## Advanced Examples ### Declaring conditional blocks #### Conditional IF {if {variable} condition value}
block to output if condition is TRUE
{/if}
OR
{if {variable} condition value}
block to output if condition is TRUE
{else}
block to output if condition returns FALSE
{/if} > the *condition* tag may take any value among ==, !=, <>, <, <=, > or >=

Conditional SWITCH

{switch {variable}}
{case first_value}
block to output if the first case matches expected value
{break}
{case second_value}
block to output if the second case matches expected value
{break}
{default}
default block to output
{break}
{/switch}

Declaring loops

{for index from start_value to end_value step step_value}
output block to loop on with the {index} displayed at each step
{/for}

Viewing indexes in an array structure

{array_name}
{index in array_name}
{/array_name}

Calling a Helper in a view

{helper_name([argument_1 [, argument_2 ...]])}
For example :

<form action="{site_url(controller/method/key1/value1/key2/value2)}" role="form" class="form-inline">

will be equivalent to :

<form action="<?php echo site_url('controller/method/key1/value1/key2/value2'); ?>" role="form" class="form-inline">

Note that, though arguments are passed to Helpers as strings, they don't require surrounding simple or double quotes when called via the Parser.

Helper calls can also be nested. For example :

{form_open({site_url(controller/method/key1/value1/key2/value2)}, role="form" class="form-inline")}

will be equivalent to :

<?php form_open(site_url('controller/method/key1/value1/key2/value2'), 'role="form" class="form-inline"'); ?>
You can’t perform that action at this time.