Popcorn - the flexible, fast, and simple template engine for PHP!

Discussion in 'PHP' started by Awilum, May 7, 2011.

  1. #1
    [​IMG]

    Hello ) I wrote this simple and powerfull template engine for PHP! Popcorn!

    Site: http://popcorn.template-cms.org/

    Built-in popcorn template codes
    {echo $var} - Output variable
    {var name $var2} - Assign local template variable
    {const name $value} - Assign constant
    {file 'filename'} - Load file
    {run function()} - Run php function
    {if expr} {else} {elseif expr} {/if}- If construct
    {loop $mas as $item}{/loop}
    {loop $mas as $key => $item}{/loop} - Loop construct
    {codes} - Show all declared template codes
    {vars} - Show all declared variables
    {dump $var} - Dumps information about a variable
    {assign var 'value'} or {assign var $value} - Assign global variable
    {include 'template_name'} - Include other template


    Simple php application
    
    <?php
    
        // Include Popcorn
        include 'popcorn/popcorn.class.php';
    
        // Initialize a Popcorn object	
        $popcorn = new Popcorn();
    
        // Variable assign
        $variable = 'Hello World!';
        $popcorn->assign('variable',$variable);
        $popcorn->assign('show',true);
    
        // Draw the template	
        $popcorn->draw('page');	
    
    ?>
    
    Code (markup):


    Simple template
    
    <html>
    <head>
        <title>Simple template</title>
    </head>
    <body>
        {if $show}	
            {echo $variable}
        {/if}
    </body>
    </html>
    
    Code (markup):

    p.s.
    TCodes - closed!
     
    Awilum, May 7, 2011 IP
  2. mofta7y

    mofta7y Member

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #2
    is there any advantages of this engine to smarty engine ?
     
    mofta7y, May 7, 2011 IP
  3. Awilum

    Awilum Member

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    + Simple syntax like PHP and smarty
    + Fast and lightweight!
    + Generate high quality code not kasha like with smarty
    + KISS principle
     
    Awilum, May 7, 2011 IP
  4. mike30

    mike30 Well-Known Member

    Messages:
    887
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    140
    #4
    Seems interesting.
    The documentation is well documented.

    I might give a try in near future.


    ~Mike
     
    mike30, May 7, 2011 IP
  5. Awilum

    Awilum Member

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #5
    Snippets for Sublime Text

    @@ - {@ $var}
    @echo - {echo $var}
    @if - {if $var} {/if}
    @ifelse - {if $var} {else} {/if}
    @ifelseif - {if $var} {elseif $var} {/if}
    @loop - {loop $key as $item} {/loop}
    @var - {var name $var2}
    @const - {const name $value}
    @assign - {assign var $value}
    @include - {include 'template_name'}
    @file - {file 'filename'}
    @run - {run function()}
    @vars - {vars}
    @codes - {codes}
    @dump - {dump $var}

    Download: popcorn.zip

    Install: Unpack the archive to a folder Sublime Text\Packages\User
     
    Awilum, May 7, 2011 IP