Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/satrun77/silverstripe-template-tags
Provide a several useful template tags.
https://github.com/satrun77/silverstripe-template-tags
php silverstripe silverstripe-4 silverstripe-template template
Last synced: 10 days ago
JSON representation
Provide a several useful template tags.
- Host: GitHub
- URL: https://github.com/satrun77/silverstripe-template-tags
- Owner: satrun77
- License: mit
- Created: 2018-09-07T08:25:02.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T22:43:55.000Z (over 1 year ago)
- Last Synced: 2024-10-20T23:15:24.525Z (27 days ago)
- Topics: php, silverstripe, silverstripe-4, silverstripe-template, template
- Language: PHP
- Homepage:
- Size: 152 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Template Tags
###### SilverStripe template parser[![Build Status](https://scrutinizer-ci.com/g/satrun77/silverstripe-template-tags/badges/build.png?b=master)](https://scrutinizer-ci.com/g/satrun77/silverstripe-template-tags/build-status/master)
[![Code Coverage](https://scrutinizer-ci.com/g/satrun77/silverstripe-template-tags/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/satrun77/silverstripe-template-tags/?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/satrun77/silverstripe-template-tags/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/satrun77/silverstripe-template-tags/?branch=master)
[![Latest Stable Version](https://poser.pugx.org/moo/template-tags/v/stable?format=flat)](https://packagist.org/packages/moo/template-tags)
[![License](https://poser.pugx.org/moo/template-tags/license?format=flat)](https://packagist.org/packages/moo/template-tags)Provide a several template tags for better template implementation. For example an improved `<% include %>`.
## Requirements
* SilverStripe CMS ^5.0
## Installation via Composer
composer require moo/template-tags## Usage
### Spaceless
Remove extra whitespaces from around the template syntax & HTML output.
```
<% spaceless %>
... Template syntax and HTML ...
<% end_spaceless %>```
### Template
An alternative to `<% include %>`
```
<% template TemplateName %>
<% set Theme %>$ClassName<% end_set %>
<% set Someone %>
Github user: {$ClassName}-{$ID}-{$MenuTitle.XML}
<% end_set %>
Hello world
<% end_template %>
```
#### Ways to define template name
- By string
```
<% template TemplateName %><% end_template %><% template 'Namespace\TemplateName' %><% end_template %>
```- By variable or method within an object
```
<% template $TemplateName %><% end_template %><% template $Object.Method %><% end_template %>
```#### The body of the template tag
- The body of the tag can include HTML, template logic, & defined arguments.
```
<% template TemplateName %>
Hello world
<% end_template %>
```- The body of the block can include other syntax such as <% include %>
```
<% template TemplateName %>
Hello world
<% include Icon %>
<% end_template %>
```- You can pass parameters, one per line! not all in same line as '<% include %>
```
<% template TemplateName %>
<% set Theme %>$Theme<% end_set %>
<% set Someone %>
Github user: {$Member.Name}
<% end_set %>
Hello world
<% end_template %>
```TemplateName.ss
`<% content %>` Placeholder for the content of the template ie. `Hello world
`
```
<% content %>
Are you a {$Someone}
```## License
This module is under the MIT license. View the [LICENSE](LICENSE.md) file for the full copyright and license information.