www.webdeveloper.com
Results 1 to 3 of 3

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

  1. #1
    Join Date
    Jun 2010
    Posts
    10

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

    Popcron!

    Hello ) I wrote this simple 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
    Code:
    <?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');	
    
    ?>


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

  2. #2
    Join Date
    May 2003
    Posts
    599
    if you have classes available, you should post them on phpclasses.org. You will get great exposure and a better chance of contribution from other developers.
    We do precision guesswork

  3. #3
    Join Date
    Jun 2010
    Posts
    10
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles