2017 © Pedro Peláez
 

silverstripe-module silverstripe-composeparser

Adds new syntax to SilverStripe's template engine

image

heyday/silverstripe-composeparser

Adds new syntax to SilverStripe's template engine

  • Sunday, June 22, 2014
  • by heyday
  • Repository
  • 26 Watchers
  • 6 Stars
  • 4,071 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 1 % Grown

The README.md

SilverStripe Compose Parser

Allows the use of an html-like syntax for template includes, and new composition functionality for more reusable templates., (*1)

Installation (with composer)

composer require heyday/silverstripe-composeparser

Examples

A reusable button

button.ss, (*2)

<% if $href %>
    <a class="btn<% if $type %> btn-$type<% end_if %><% if $size %> btn-$size<% end_if %> $classes" href="$href"><% composed %></a>
<% else %>
    <button class="btn<% if $type %> btn-$type<% end_if %><% if $size %> btn-$size<% end_if %> $classes"><% composed %></button>
<% end_if %>

Using the button in a template

<:button type="default">A regular button</:button>

<:button type="default" href="http://heyday.co.nz">A link to heyday</:button>

The resulting html

<button class="btn btn-default">A regular button</button>

<a class="btn btn-default" href="http://heyday.co.nz/">A link to heyday</a>

A reusable Nav

nav.ss, (*3)

<ul class="nav <% if $classes %> $classes<% end_if %>"><% composed %></ul>

navitem.ss, (*4)

<li class="nav-item<% if $FirstLast %> nav-$FirstLast<% end_if %><% if $classes %> $classes<% end_if %>">
    <% if $Composed %>
        <% composed %>
    <% else %>
        <:navlink href=$href />
    <% end_if %>
</li>

navlink.ss, (*5)

<a href="$href" class="$LinkingMode"><% if $Composed %><% composed %><% else %>$MenuTitle<% end_if %></a>

Using the nav

Simple usage:
<:nav>
    <% loop $SomeSet %>
        <:navitem href=$Link />
    <% end_loop %>
</:nav>

Customised usage:
<:nav>
    <% loop $SomeSet %>
        <:navitem>
            <% if $SomeCondition %><span class="i-special-icon"></span><% end_if %>
            <navlink href=$Link/>
        </:navitem>
    <% end_loop %>
</:nav>

The Versions

22/06 2014

dev-master

9999999-dev

Adds new syntax to SilverStripe's template engine

  Sources   Download

MIT

22/06 2014

0.1.1

0.1.1.0

Adds new syntax to SilverStripe's template engine

  Sources   Download

MIT

27/11 2013

0.1.0

0.1.0.0

Adds new syntax to SilverStripe's template engine

  Sources   Download

MIT