function jade($fn, $file = false, $deps = array()) { global $jade; $time = @filectime($fn); foreach ($deps as $dn) { $x = @filectime($dn); if ($x === FALSE) { break; } if ($x > $time) { $time = $x; } } if ($time === FALSE) { die("can't open jade file '{$fn}'"); } if (!isset($jade) || !$jade) { $jade = new Jade\Jade(true); } if ($file) { $cn = "cache" . DIRECTORY_SEPARATOR . "{$fn}.php"; $to = @filectime($pn); if ($to === FALSE || $to < $time) { file_put_contents($cn, $jade->render($fn)); } return $cn; } return $jade->render($fn); }
public function run($force = false) { $jade = new Jade\Jade(); $dir = "application/views/"; $template_files = getJadeFiles($dir); foreach ($template_files as $tf) { $phpver = str_replace(".jade", ".php", $tf); if ($force || !file_exists($dir . $phpver) || filemtime($dir . $tf) > filemtime($dir . $phpver)) { echo "compiling " . $dir . $phpver . "\n"; $output = $jade->render(File::get($dir . $tf)); file_put_contents($dir . $phpver, $output); } } }
/** * 変換処理の実行 * @param object $px Picklesオブジェクト */ public static function exec_ext($px) { $data = $px->site()->get_current_page_info(); foreach ($px->bowl()->get_keys() as $key) { $src = $px->bowl()->pull($key); // Using Library "ronan-gloo/jade-php" ==> see https://github.com/ronan-gloo/jade-php $jade = new \Jade\Jade(['prettyprint' => true]); ob_start(); $results = $jade->render($src, $data); $src = ob_get_clean(); $src = $px->bowl()->replace($src, $key); } return true; }
function jade($template) { $templates = kirby::instance()->roots()->templates(); // Closure to recursively get the modification time from jade templates and // their super templates (determeined by pre-parsing 'extends' statements). $getChangeTime = function ($template, $time) use(&$getChangeTime, $templates) { $file = "{$templates}/{$template}.jade"; $t = @filectime($file); if ($t === false) { die("Can't open jade file '{$file}'"); } if ($t > $time) { $time = $t; } $fp = fopen($file, 'r'); // Find all the lines of the template that contains an valid statements, // and see there are any 'extends' or 'include' statements to determine // dependencies. while (true) { $line = fgets($fp); if ($line === false) { break; } $line = trim($line); if (!$line || !strncmp($line, '//', 2)) { continue; } if (!strncmp($line, 'extends ', 8) || !strncmp($line, 'include ', 8)) { $time = $getChangeTime(substr($line, 8), $time); } } fclose($fp); return $time; }; $time = $getChangeTime($template, 0); static $jade = null; if (!isset($jade) || !$jade) { $jade = new Jade\Jade(true); } $cache = kirby::instance()->roots()->cache() . DS . "{$template}.jade.php"; $t = @filectime($cache); // Now get the modification time from the cached file, and regenerate if // the jade template or any of its dependencies have changed. if ($t === false || $t < $time) { file_put_contents($cache, $jade->render("{$templates}/{$template}.jade")); } return $cache; }
function HtmlPreprocessor($content, $type) { if ($type == 'markdown') { $Parsedown = new ParsedownExtra(); $content = $Parsedown->text($content); } else { if ($type == 'jade') { $jade = new \Jade\Jade(); $content = $jade->render($content); } else { if ($type == 'haml') { } else { if ($type == 'html') { } } } } return $content; }
function show_php($file) { $jade = new \Jade\Jade(true); return $jade->render($file); }
function show_php($file) { $jade = new \Jade\Jade(true); //return htmlspecialchars($jade->render($file)); return $jade->render($file); }
<?php Event::listen(View::loader, function ($bundle, $view) { // This event just makes the View class think that ".jade" files are valid... $path = Bundle::path($bundle) . 'views/' . $view . '.jade'; if (file_exists($path)) { return $path; } }); Event::listen(View::engine, function ($view) { if (!str_contains(File::extension($view->path), 'jade')) { return $view->get(); } // First pass through the PHP layer... $contents = $view->get(); $jade = new Jade\Jade(); // Store the rendered Jade content... $path = path('storage') . 'views/' . md5($view->view); file_put_contents($path, $jade->render($contents)); $view->path = $path; // Render the final Jaded output... return $view->get(); });
public function render($file, $vars = []) { $jade = new \Jade\Jade(); echo $jade->render('views/' . $file . '.jade', $vars); }