This repository has been archived by the owner on Oct 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from Shan1024/string-helpers-changes
Adding demos to features app for Handlebars helpers
- Loading branch information
Showing
47 changed files
with
1,398 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ bindings: | |
|
||
config: | ||
appName: "Features App" | ||
highlightjsTheme: "tomorrow" |
112 changes: 63 additions & 49 deletions
112
...pps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/each.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 40 additions & 31 deletions
71
.../apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/if.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,74 @@ | ||
{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} | ||
{{title "if | Block Helper Sample | " @config.appName}} | ||
{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} | ||
|
||
{{#fillZone "content"}} | ||
<h3>The 'if' Block Helper.</h3> | ||
<h3><b>if</b> Helper</h3> | ||
<hr /> | ||
<p>You can use the 'if' helper to conditionally render a block.</p> | ||
<p>If its argument returns false, undefined, null, "", 0, or [], Handlebars will not render the block.</p> | ||
<pre> | ||
<figure class="highlight"> | ||
<pre class="code lang-handlebars"> | ||
<div class="entry"> | ||
\{{#if author}} | ||
<h3>\{{firstName}} \{{lastName}}</h3> | ||
\{{/if}} | ||
</div> | ||
</pre> | ||
</div></pre> | ||
</figure> | ||
<p>Example: </p> | ||
<pre> | ||
<figure class="highlight"> | ||
<pre class="code lang-json"> | ||
{ | ||
author: { | ||
firstName: "John", | ||
lastName: "Samuel" | ||
} | ||
} | ||
</pre> | ||
firstName: "John", | ||
lastName: "Samuel" | ||
} | ||
}</pre> | ||
</figure> | ||
<p>will result in:</p> | ||
<pre> | ||
<figure class="highlight"> | ||
<pre class="code lang-handlebars"> | ||
<div class="entry"> | ||
<h3>John Samuel</h3> | ||
</div> | ||
</pre> | ||
</div></pre> | ||
</figure> | ||
<h3>output:</h3> | ||
<h3>John Samuel</h3> | ||
<p>When used with an empty ({}) context, author will be undefined, resulting in:</p> | ||
<pre> | ||
<figure class="highlight"> | ||
<pre class="code lang-handlebars"> | ||
<div class="entry"> | ||
</div> | ||
</pre> | ||
</div></pre> | ||
</figure> | ||
<p>When using a block expression, you can specify a template section to run if the expression returns a falsy value. | ||
The section, marked by \{{else}} is called an "else section". | ||
The section, marked by \{{else}} is called an "else section". | ||
</p> | ||
<pre> | ||
<figure class="highlight"> | ||
<pre class="code lang-handlebars"> | ||
<div class="entry"> | ||
\{{#if author}} | ||
<h3>\{{firstName}} \{{lastName}}</h3> | ||
\{{else}} | ||
<h1>Unknown Author</h1> | ||
\{{/if}} | ||
</div> | ||
</pre> | ||
\{{#if author}} | ||
<h3>\{{firstName}} \{{lastName}}</h3> | ||
\{{else}} | ||
<h1>Unknown Author</h1> | ||
\{{/if}} | ||
</div></pre> | ||
</figure> | ||
<p> | ||
Lets see an example which render the else section: | ||
</p> | ||
<pre> | ||
<figure class="highlight"> | ||
<pre class="code lang-json"> | ||
{ | ||
author: false | ||
} | ||
</pre> | ||
}</pre> | ||
</figure> | ||
<p>will result in:</p> | ||
<pre> | ||
<figure class="highlight"> | ||
<pre class="code lang-handlebars"> | ||
<div class="entry"> | ||
<h3>Unknown Author</h3> | ||
</div> | ||
</pre> | ||
</div></pre> | ||
</figure> | ||
<h3>output: </h3> | ||
<h3>Unknown Author</h3> | ||
{{/fillZone}} |
11 changes: 6 additions & 5 deletions
11
...ps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/index.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} | ||
{{title "Block Helpers | " @config.appName}} | ||
|
||
{{#fillZone "content"}} | ||
<h3>Block Helpers : </h3> | ||
<h3>Block Helpers</h3> | ||
<hr /> | ||
<ul> | ||
<li><a href="{{@contextPath}}/helpers/block-helpers/if">The 'if' Block Helper</a></li> | ||
<li><a href="{{@contextPath}}/helpers/block-helpers/unless">The 'unless' Block Helper</a></li> | ||
<li><a href="{{@contextPath}}/helpers/block-helpers/each">The 'each' Block Helper</a></li> | ||
<li><a href="{{@contextPath}}/helpers/block-helpers/with">The 'with' Block Helper</a></li> | ||
<li><a href="{{@contextPath}}/helpers/block-helpers/each">each</a></li> | ||
<li><a href="{{@contextPath}}/helpers/block-helpers/if">if</a></li> | ||
<li><a href="{{@contextPath}}/helpers/block-helpers/unless">unless</a></li> | ||
<li><a href="{{@contextPath}}/helpers/block-helpers/with">with</a></li> | ||
</ul> | ||
{{/fillZone}} |
26 changes: 15 additions & 11 deletions
26
...s/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/unless.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.