heyday/silverstripe-templatehelpers

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

Simple template functionality for Silverstripe

Installs: 2 629

Dependents: 0

Suggesters: 0

Stars: 5

Watchers: 26

Forks: 2

Open Issues: 0

Type:silverstripe-module

2.0.3 2017-12-08 02:05 UTC

README

A library with common functionality used by SilverStripe template developers.

Thi smodule is now SilverStripe 4 compatible

For a SilverStripe 3.* compatible version see branch 0.2. For a SilverStripe 2.4 compatible version see branch 0.1.

Installation (with composer)

$ composer require heyday/silverstripe-templatehelpers

Usage

Once installed, the following functions are available in any .ss template:

  • $isDev - If the site is running in a development environment
  • $isTest - If the site is running in a test environment
  • $isLive - If the site is running in a production environment
  • $ImagePath('my-image.png') - Build an image path based on config for the current environment
  • $addInlineScript('/path/in/theme/directory/file.js') - include a javascript file verbatim in the template (note that <script> tags aren't generated automatically, so you'll need to add those around this call).

$ImagePath config

The image path helper defaults to themes/[theme]/images/. The path within the theme directory can be configured in your project's YAML config:

TemplateHelpers:
  dev_images: source/images
  prod_images: production/images