openclerk/pages

There is no license information available for the latest version (0.2.2) of this package.

0.2.2 2017-09-11 07:48 UTC

This package is auto-updated.

Last update: 2024-02-14 08:16:49 UTC


README

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