Skip to content

openclerk/pages

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Asset pipeline

The asset pipeline is designed so that you include all assets on every page. There is no automation for including multiple assets together.

Using

Create a new folder templates\ and create templates\header.php and templates\footer.php optionally (or else the framework will use the default supplied templates).

// inc/global.php

use \Pages\PageRenderer;
use \Openclerk\Router;

PageRenderer::addTemplatesLocation(__DIR__ . "/../templates");
PageRenderer::addStylesheet(Router::urlFor("css/default.css"));
PageRenderer::addJavascript(Router::urlFor("js/default.js"));
<?php
// templates/index.php

if ($user) {
  echo "<h2>Logged in successfully as $user</h2>";
} else {
  echo "<h2>Could not log in</a>";
}
?>
// site/index.php

use \Pages\PageRenderer;

$user = get_user();

PageRenderer::header(array("title" => "My page title"));
PageRenderer::requireTemplate("index", array('user' => $user));
PageRenderer::footer();

HAML

You can also define templates with HAML syntax:

/ templates/index.haml

- if($user)
  %h2 Logged in successfully as #{$user}
- else
  %h2 Could not log in

!= link_to(url_for("index"), "Back home")

Events

A number of events are triggered by the library, and can be captured for metrics:

  • pages_header_start, pages_header_end
  • pages_footer_start, pages_footer_end
  • pages_template_start, pages_template_end

About

Simple PHP page templates and rendering

Resources

Stars

Watchers

Forks

Packages

No packages published