Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 246 lines (186 sloc) 4.65 KB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Twig Examples</title>
<!-- Styles -->
<style>
html, body {
background-color: #fff;
color: #4f5558;
font-family: sans-serif;
font-weight: 100;
height: 100vh;
margin: 10px 10px 0 10px;
font-size: 14px;
}
section {
margin: 25px 0 0 8px;
}
section:first-of-type {
margin-top: 15px;
}
h1 {
margin:0;
}
h2 {
margin: 0;
}
h2:first-child {
margin-top:0;
}
p {
margin-left: 10px;
}
.entry {
margin-left: 10px;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 1px solid #ccc;
}
.entry-body {
margin-bottom: 50px;
}
.entry-meta {
font-style: italic;
margin: 10px 0;
}
.entry-date-field {
margin: 10px 0;
}
</style>
</head>
<body>
<h1>Code Examples!</h1>
<section>
<h2>Available Plugins</h2>
<ul>
{% for plugin in Plugins.pluginsList %}
<li>{{ plugin.plugin_name }}</li>
{% endfor %}
</ul>
</section>
<section>
<h2>Plugin Filters</h2>
<p>
<strong>I Am Groot:</strong>
{{ "I like kangaroos. Fond of most marsupials–usually–really." | iamgroot }}
</p>
</section>
<section>
<h2>Plugin Variables</h2>
<p>
<strong>Groot: </strong> {{groot.speak}}
</p>
</section>
<section>
<h2>Plugin Functions</h2>
<p>
<strong>Markdown:</strong> {{ markdown('### Heading 3') }}
</p>
<p>
<strong>Email Encode Javascript: {{ "<a href='mailto:demo@kilvincms.com'>demo@kilvincms.com</a>" | encodeEmailJs | raw }}
</p>
</section>
<section>
<h2>Plugin Models</h2>
<ul>
{% for entry in Plugins.Element('Entries').status(['open', 'closed']).first() %}
<h3>{{ entry.fields.title }}</h3>
<div class="entry">
<div class="entry-body">
{{ entry.fields.body | markdown | raw }}
</div>
{% if entry.fields is defined and entry.fields.special_date is defined %}
<div class="entry-date-field">
<strong>Special Date:</strong>
{{ entry.fields.special_date | date('M j, Y H:i A') }}
</div>
{% endif %}
<div class="entry-meta">
<strong>Entry Date:</strong>
{% if entry.entry_date|daysAgo < 1 %}
{{ entry.entry_date | relativeDate }} ago
{% else %}
{{ entry.entry_date | date('M j, Y') }}
{% endif %}
</div>
</div>
{% endfor %}
</ul>
</section>
<section>
<h2>Laravel Facades and Helpers</h2>
<p>
<strong>Screen Name:</strong>
{% if Auth.id is not empty %}
{{ Auth.user.screen_name }}
{% else %}
Not logged in ¯\_(ツ)_/¯
{% endif %}
</p>
<p>
<strong>App Name:</strong> {{ Config.get('app.name') }}
</p>
<p>
<strong>URL:</strong> {{ Request.fullUrl() }}
</p>
<p>
<strong>Path:</strong> {{ Request.path() }}
</p>
<p>
<strong>CSRF Token:</strong> {{ csrfToken() }}
</p>
<p>
<strong>Secure URL:</strong> {{ secureUrl('testing') }}
</p>
<p>
<strong>URL (secure):</strong> {{ URL.secure('testing') }}
</p>
<p>
<strong>Session Incrementing:</strong> {{ Session.increment('fun') }}
</p>
</section>
<section>
<h2>Kilvin CMS Facades and Helpers</h2>
<p>
<strong>Site Online?</strong> {{ Site.config('is_site_on') }}
</p>
<p>
<strong>Site Name: </strong> {{ Site.config('site_name') }}
</p>
<p>
<strong>CP URL: </strong> {{ Site.config('cp_url') }}
</p>
<p>
<strong>Most Recent Entry:</strong> <a href="#">{{ Plugins.Weblogs.mostRecent().title }}</a>
</p>
</section>
<section>
<h2>Template Variables and Globals</h2>
<p>
<strong>Global CMS Variable:</strong> {{cms.version}}
</p>
<p>
<strong>Now (site localized):</strong> {{now|date('Y/m/d H:i')}}
</p>
<p>
<strong>UTC :</strong> {{utc|date('Y/m/d H:i')}}
</p>
</section>
<section>
<h2>Functions</h2>
<p>
<strong>Ceil:</strong> {{ ceil(5.3) }}
</p>
<p>
<strong>Floor:</strong> {{ floor(5.3) }}
</p>
<p>
{% set π = pi() %}
<strong>Pi Rounded:</strong> {{ round(π, 2) }}
</p>
</section>
</body>
</html>