Skip to content

Instantly share code, notes, and snippets.

@mgng
Created May 10, 2012 01:09
Show Gist options
  • Save mgng/2650227 to your computer and use it in GitHub Desktop.
Save mgng/2650227 to your computer and use it in GitHub Desktop.
Twig sample
私の名前は{{name}}です。
compilation_cache
├─0b
│ └fc
│ └bd58afe05991c85d5c257bd2e549.php
└─39
└47
└76d77f721495e2e98fe30ddae1bb.php
<?php
require_once '/path/to/lib/Twig/Autoloader.php';
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem( '/path/to/view/template' );
$twig = new Twig_Environment( $loader, array(
'cache' => '/path/to/view/compilation_cache',
'charset' => 'utf-8',
'auto_reload' => true,
// 'autoescape' => false,
));
echo $twig->render( 'index.html', array( 'name' => 'mgng' ) );
<?php
require_once '/path/to/lib/Twig/Autoloader.php';
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem( '/path/to/view/template' );
$twig = new Twig_Environment( $loader, array(
// 'cache' => '/path/to/view/compilation_cache',
'cache' => false,
'charset' => 'utf-8',
'auto_reload' => true,
// 'autoescape' => false,
));
echo $twig->render( 'index.html', array( 'name' => 'mgng' ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment