Standalone Skeltch templating engine for PHP

Overview

SkeltchGo

SkeltchGo is a standalone version of Glowie Skeltch templating engine for PHP, intented to use from outside the framework.

Requirements

  • PHP version 7.4 or higher
  • Composer version 2.0 or higher

Installation

composer require glowieframework/skeltchgo

Usage

Create an SkeltchGo instance through the static make() method.

use Glowie\SkeltchGo\SkeltchGo;
$skeltch = SkeltchGo::make();

This method returns an instance of ViewRenderer.

The make() method accepts three optional arguments:

  • viewFolder (string) - Folder where the view files are stored, relative to the running script. (Defaults to views)
  • cache (bool) - Enable views caching. Highly recommended in a production environment. (Defaults to true)
  • cacheFolder (string) - View cache folder, relative to the running script. Must have writing permissions. (Defaults to cache)

Rendering views

Views must be .phtml files inside the views folder. Extension is not needed.

From the script

$skeltch->renderView('myView');

From another view

{@view('myView')}

Rendering layouts

Layouts must be .phtml files inside the views folder. Extension is not needed. The second parameter is an optional view file to render within the layout.

From the script

$skeltch->renderLayout('myLayout', 'myView');

From another view

{@layout('myLayout', 'myView')}

To retrieve the internal view content inside the layout use:

{@content}

Passing parameters

There are two ways of passing parameters to the views:

// Globally to all views
$skeltch->view->param1 = 'Lorem ipsum';

// Restricted to a single view
$skeltch->renderView('myView', [
    'param2' => 'Hello world'
]);

Then retrieve it in the view as a property of itself:

{{$this->param1}}

View helpers

Setup a helper method by passing a name and a closure to the helper() method:

$skeltch->helper('sayHello', function($name){
    return "Hello, $name!";
});

And call it in your view file using:

{{$this->sayHello('World')}}

Full documentation

To learn how to use all methods and templating syntax, read Skeltch complete documentation.

Note: some Skeltch methods are restricted to the framework environment and are not available in SkeltchGo. Unavailable methods are: babel, url, route, asset and csrf.

Credits

SkeltchGo and Glowie are currently being developed by Gabriel Silva.

You might also like...
⚡️ Simple and fastly template engine for PHP

EasyTpl ⚡️ Simple and fastly template engine for PHP Features It's simple, lightweight and fastly. No learning costs, syntax like PHP template It is s

Twig Template Engine to Phalcon PHP

Twig Template Engine to Phalcon PHP

Liquid template engine for PHP

Liquid is a PHP port of the Liquid template engine for Ruby, which was written by Tobias Lutke. Although there are many other templating engines for PHP, including Smarty (from which Liquid was partially inspired)

Pug (Jade) template engine for Symfony

Pug-Symfony Pug template engine for Symfony This is the documentation for the ongoing version 3.0. Click here to load the documentation for 2.8 Instal

PHPlater, a simple template engine.

PHPlater A simple PHP template engine that lets PHP do all the logic and then append it to the HTML in the template file. It is set to solve the probl

A PHP project template with PHP 8.1, Laminas Framework and Doctrine

A PHP project template with PHP 8.1, Laminas Framework and Doctrine

Twig, the flexible, fast, and secure template language for PHP
Twig, the flexible, fast, and secure template language for PHP

Twig, the flexible, fast, and secure template language for PHP Twig is a template language for PHP, released under the new BSD license (code and docum

A Mustache implementation in PHP.

Mustache.php A Mustache implementation in PHP. Usage A quick example: ?php $m = new Mustache_Engine(array('entity_flags' = ENT_QUOTES)); echo $m-re

Native PHP template system

Plates Plates is a native PHP template system that's fast, easy to use and easy to extend. It's inspired by the excellent Twig template engine and str

Releases(v1.0.1)
Owner
glowie
Glowie is a PHP framework designed to be as light, fast and powerful as possible for developing applications and dynamic websites the easiest way.
glowie
Experimental ActiveRecord layer on top of Doctrine2 using the Twig templating engine

This is an experiment for building ActiveRecord functionality on top of Doctrine2 using the Twig templating engine. Whether it is called Propel2 or not is irrelevant.

Francois Zaninotto 85 Dec 5, 2022
Provides TemplateView and TwoStepView using PHP as the templating language, with support for partials, sections, and helpers.

Aura View This package provides an implementation of the TemplateView and TwoStepView patterns using PHP itself as the templating language. It support

Aura for PHP 83 Jan 3, 2023
A faster, safer templating library for PHP

Brainy Brainy is a replacement for the popular Smarty templating language. It is a fork from the Smarty 3 trunk. Brainy is still very new and it's lik

Box 66 Jan 3, 2023
Simple PHP templating system for user editable templates.

Simple template Simple PHP templating system for user editable templates. Idea Most applications need to render templates that insert safely treated v

Baraja packages 1 Jan 23, 2022
The Templating component provides all the tools needed to build any kind of template system.

Templating Component The Templating component provides all the tools needed to build any kind of template system. It provides an infrastructure to loa

Symfony 999 Dec 25, 2022
PHP template engine for native PHP templates

FOIL PHP template engine, for PHP templates. Foil brings all the flexibility and power of modern template engines to native PHP templates. Write simpl

Foil PHP 167 Dec 3, 2022
Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic.

Smarty 3 template engine smarty.net Documentation For documentation see www.smarty.net/docs/en/ Requirements Smarty can be run with PHP 5.2 to PHP 7.4

Smarty PHP Template Engine 2.1k Jan 1, 2023
☕ Latte: the intuitive and fast template engine for those who want the most secure PHP sites.

Latte: amazing template engine for PHP Introduction Latte is a template engine for PHP which eases your work and ensures the output is protected again

Nette Foundation 898 Dec 25, 2022
PHP Template Attribute Language — template engine for XSS-proof well-formed XHTML and HTML5 pages

PHPTAL - Template Attribute Language for PHP Requirements If you want to use the builtin internationalisation system (I18N), the php-gettext extension

PHPTAL 175 Dec 13, 2022
View template engine of PHP extracted from Laravel

Blade 【简体中文】 This is a view templating engine which is extracted from Laravel. It's independent without relying on Laravel's Container or any others.

刘小乐 143 Dec 13, 2022