PHP code example of heyday / silverstripe-composeparser

1. Go to this page and download the library: Download heyday/silverstripe-composeparser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

heyday / silverstripe-composeparser example snippets


<% 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 %>

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

<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>

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

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>