diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/app.yaml b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/app.yaml index 363316fa..79bac43b 100644 --- a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/app.yaml +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/app.yaml @@ -43,6 +43,8 @@ menus: submenus: - text: "Block Helpers" link: "/helpers/block-helpers" + - text: "String Helpers" + link: "/helpers/string-helpers" errorPages: 404: /foundation/error/404 diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/component.yaml b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/component.yaml index dba484af..14f65f7b 100644 --- a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/component.yaml +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/component.yaml @@ -10,3 +10,4 @@ bindings: config: appName: "Features App" + highlightjsTheme: "tomorrow" diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/each.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/each.hbs index abc92afd..ca9d6449 100644 --- a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/each.hbs +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/each.hbs @@ -1,35 +1,40 @@ {{layout "org.wso2.carbon.uuf.sample.foundation.main"}} {{title "each | Block Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + {{#fillZone "content"}} -

The 'each' Block Helper.

+

each Helper


You can iterate over a list using the 'each' helper.

Inside the block, you can use this to reference the element being iterated over.

-
+    
+
         <ul class="people_list">
-          \{{#each people}}
+            \{{#each people}}
                 <li>\{{this}}</li>
-          \{{/each}}
-        </ul<
-    
+ \{{/each}} + </ul>
+

For example:

-
+    
+
         {
           people: [
             "Yehuda Katz",
             "Alan Johnson",
             "Charles Jolley"
           ]
-        }
-    
+ }
+

will result in:

-
+    
+
         <ul class="people_list">
-          <li>Yehuda Katz</li>
-          <li>Alan Johnson</li>
-          <li>Charles Jolley</li>
-        </ul>
-    
+ <li>Yehuda Katz</li> + <li>Alan Johnson</li> + <li>Charles Jolley</li> + </ul>
+

output:

You can use this expression in any context to reference the current context.

-

You can optionally provide an \{{else}} section which will display only when the list is empty.

-

-        \{{#each paragraphs}}
-          <p>\{{this}}</p>
-        \{{else}}
-          <p class="empty">No content</p>
-        \{{/each}}
-    
+

You can optionally provide an \{{else}} section which will display only when the list is empty. +

+

+
+            \{{#each paragraphs}}
+                <p>\{{this}}</p>
+                \{{else}}
+                <p class="empty">No content</p>
+            \{{/each}}
+

When looping through items in each, you can optionally reference the current loop index via \{{@index}}

-
+    
+
         \{{#each people}}
-          \{{@index}}: \{{this}}
-        \{{/each}}
-    
+ \{{@index}}: \{{this}} + \{{/each}}
+

Example:

-
+    
+
         {
             people: [
                 "Yehuda Katz",
                 "Alan Johnson",
                 "Charles Jolley"
                 ]
-        }
-    
+ }
+

output:

-
+    
+
         0: Yehuda Katz
         1: Alan Johnson
-        2: Charles Jolley
-    
+ 2: Charles Jolley
+

Additionally for object iteration, \{{@key}} references the current key name:

-
+    
+
         \{{#each people}}
-          \{{@key}}: \{{this}}
-        \{{/each}}
-    
+ \{{@key}}: \{{this}} + \{{/each}}
+

Example:

-
+    
+
         {
             people: [
                 "first" => "Yehuda Katz",
                 "second" => "Alan Johnson",
                 "third" => "Charles Jolley"
                 ]
-        }
-    
+ }
+

output:

-
+    
+
         first: Yehuda Katz
         second: Alan Johnson
-        third: Charles Jolley
-    
+ third: Charles Jolley
+

The first and last steps of iteration are noted via the @first and @last variables when iterating over an array. When iterating over an object only the @first is available. @@ -96,13 +109,14 @@ To access the parent index, for example, \{{@../index}} can be used.

The each helper also supports block parameters, allowing for named references anywhere in the block.

-
+    
+
         \{{#each array as |value key|}}
-          \{{#each child as |childValue childKey|}}
-            \{{key}} - \{{childKey}}. \{{childValue}}
-          \{{/each}}
-        \{{/each}}
-    
+ \{{#each child as |childValue childKey|}} + \{{key}} - \{{childKey}}. \{{childValue}} + \{{/each}} + \{{/each}}
+

Will create a key and value variable that children may access without the need for depth variable references.

In the example above, \{{key}} is identical to \{{@../key}} but in many cases is more readable.

diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/if.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/if.hbs index ce3868e1..bdbd91e0 100644 --- a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/if.hbs +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/if.hbs @@ -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"}} -

The 'if' Block Helper.

+

if Helper


You can use the 'if' helper to conditionally render a block.

If its argument returns false, undefined, null, "", 0, or [], Handlebars will not render the block.

-
+    
+
         <div class="entry">
             \{{#if author}}
                 <h3>\{{firstName}} \{{lastName}}</h3>
             \{{/if}}
-        </div>
-    
+ </div>
+

Example:

-
+    
+
         {
             author: {
-                        firstName: "John",
-                        lastName: "Samuel"
-                    }
-        }
-    
+ firstName: "John", + lastName: "Samuel" + } + }
+

will result in:

-
+    
+
         <div class="entry">
             <h3>John Samuel</h3>
-        </div>
-    
+ </div>
+

output:

John Samuel

When used with an empty ({}) context, author will be undefined, resulting in:

-
+    
+
         <div class="entry">
-        </div>
-    
+ </div>
+

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

-
+    
+
         <div class="entry">
-          \{{#if author}}
-            <h3>\{{firstName}} \{{lastName}}</h3>
-          \{{else}}
-            <h1>Unknown Author</h1>
-          \{{/if}}
-        </div>
-    
+ \{{#if author}} + <h3>\{{firstName}} \{{lastName}}</h3> + \{{else}} + <h1>Unknown Author</h1> + \{{/if}} + </div>
+

Lets see an example which render the else section:

-
+    
+
         {
             author: false
-        }
-    
+ }
+

will result in:

-
+    
+
         <div class="entry">
             <h3>Unknown Author</h3>
-        </div>
-    
+ </div>
+

output:

Unknown Author

{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/index.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/index.hbs index b894cd5d..b9ece209 100644 --- a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/index.hbs +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/index.hbs @@ -1,12 +1,13 @@ {{layout "org.wso2.carbon.uuf.sample.foundation.main"}} {{title "Block Helpers | " @config.appName}} + {{#fillZone "content"}} -

Block Helpers :

+

Block Helpers


{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/unless.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/unless.hbs index f0f0e7aa..3564c24c 100644 --- a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/unless.hbs +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/unless.hbs @@ -1,23 +1,27 @@ {{layout "org.wso2.carbon.uuf.sample.foundation.main"}} {{title "unless | Block Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + {{#fillZone "content"}} -

The 'unless' Block Helper.

+

unless Helper


You can use the 'unless' helper as the inverse of the 'if' helper.

Its block will be rendered if the expression returns a falsy value.

-
+    
+
         <div class="entry">
-          \{{#unless license}}
-            <h3>WARNING: This entry does not have a license!</h3>
-          \{{/unless}}
-        </div>
-    
+ \{{#unless license}} + <h3>WARNING: This entry does not have a license!</h3> + \{{/unless}} + </div>
+

Example:

-
+    
+
         {
-            "license" = false;
-        }
-    
+ license: false + }
+

output:

WARNING: This entry does not have a license!

diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/with.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/with.hbs index 58b4e863..bfa242a0 100644 --- a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/with.hbs +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/block-helpers/with.hbs @@ -1,46 +1,51 @@ {{layout "org.wso2.carbon.uuf.sample.foundation.main"}} {{title "with | Block Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + {{#fillZone "content"}} -

The 'with' Block Helper.

+

with Helper


Normally, Handlebars templates are evaluated against the context passed into the compiled method.

-
+    
+
         var source   = "<p>\{{lastName}}, \{{firstName}}</p>";
         var template = Handlebars.compile(source);
-        template({firstName: "Alan", lastName: "Johnson"});
-    
+ template({firstName: "Alan", lastName: "Johnson"});
+

will result in:

-
-        <p>Johnson, Alan</p>
-    
+
+
+        <p>Johnson, Alan</p>
+

You can shift the context for a section of a template by using the 'with' helper.

-
+    
+
         <div class="entry">
-          <h1>\{{title}}</h1>
-
-          \{{#with author}}
-          <h2>By \{{firstName}} \{{lastName}}</h2>
-          \{{/with}}
-        </div>
-    
+ <h1>\{{title}}</h1> + \{{#with author}} + <h2>By \{{firstName}} \{{lastName}}</h2> + \{{/with}} + </div>
+

For example:

-
+    
+
         {
-          title: "My first post!",
-          author: {
-            firstName: "Charles",
-            lastName: "Jolley"
-          }
-        }
-    
+ title: "My first post!", + author: { + firstName: "Charles", + lastName: "Jolley" + } + }
+

will result in:

-
+    
+
         <div class="entry">
           <h1>My first post!</h1>
-
           <h2>By Charles Jolley</h2>
-        </div>
-    
+ </div>
+

output:

My first post!

@@ -49,23 +54,24 @@ 'with' can also be used with block parameters to define known references in the current block. The example above can be converted to,

-
+    
+
         <div class="entry">
-          <h1>\{{title}}</h1>
-
-          \{{#with author as |myAuthor|}}
-          <h2>By \{{myAuthor.firstName}} \{{myAuthor.lastName}}</h2>
-          \{{/with}}
-        </div>
-    
+ <h1>\{{title}}</h1> + \{{#with author as |myAuthor|}} + <h2>By \{{myAuthor.firstName}} \{{myAuthor.lastName}}</h2> + \{{/with}} + </div>
+

which allows for complex templates to potentially provide clearer code than ../ depth references allow for.

You can optionally provide an \{{else}} section which will display only when the passed value is empty.

-
-        \{{#with author}}
-          <p>\{{name}}</p>
-        \{{else}}
-          <p class="empty">No content</p>
-        \{{/with}}
-    
+
+
+            \{{#with author}}
+                <p>\{{name}}</p>
+            \{{else}}
+                <p class="empty">No content</p>
+            \{{/with}}
+

{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/index.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/index.hbs index 1932f438..35ece213 100644 --- a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/index.hbs +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/index.hbs @@ -5,5 +5,6 @@
{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/abbreviate.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/abbreviate.hbs new file mode 100644 index 00000000..49b4b95a --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/abbreviate.hbs @@ -0,0 +1,42 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Abbreviate | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

abbreviate Helper

+
+

Truncates a string if it is longer than the specified number of characters. Truncated strings will end with a + translatable ellipsis sequence ("...").

+ +
+
+
\{{abbreviate <value> <size>]}}
+
+

value - string to truncate

+

size - number of characters to show

+
+ +
+

Example

+
+
+            <div>
+                \{{abbreviate value size}}
+            </div>
+
+

when used with this context:

+
+
+                {
+                    value: "Handlebars rocks"
+                }
+
+

will result in:

+
+
+            <div>
+                {{abbreviate value size}}
+            </div>
+
+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/abbreviate.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/abbreviate.js new file mode 100644 index 00000000..13df2e6c --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/abbreviate.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "Handlebars rocks", + size: 13 + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/capitalize-first.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/capitalize-first.hbs new file mode 100644 index 00000000..1af22dbf --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/capitalize-first.hbs @@ -0,0 +1,40 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Capitalize-First | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

capitalizeFirst Helper

+
+

Capitalizes the first character of a sentence.

+ +
+
+
\{{capitalizeFirst value}}
+

value - string to capitalize

+
+
+ +
+

Example

+
+
+            <div>
+                \{{capitalizeFirst value}}
+            </div>
+
+

when used with this context:

+
+
+                {
+                    value: "handlebars.java"
+                }
+
+

will result in:

+
+
+            <div>
+                {{capitalizeFirst value}}
+            </div>
+
+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/capitalize-first.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/capitalize-first.js new file mode 100644 index 00000000..8362d3b1 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/capitalize-first.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "handlebars.java" + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/capitalize.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/capitalize.hbs new file mode 100644 index 00000000..d37a560f --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/capitalize.hbs @@ -0,0 +1,41 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Capitalize | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

capitalize Helper

+
+

Capitalizes all the whitespace separated words in a String.

+ +
+
+
\{{capitalize <value> [fully=false]}}
+
+

value - string to capitalize

+

fully - optional boolean to identify whether to fully capitalize the string or not

+
+ +
+

Example

+
+
+            <div>
+                \{{capitalize value}}
+            </div>
+
+

when used with this context:

+
+
+                {
+                    value: "my first post"
+                }
+
+

will result in:

+
+
+            <div>
+                {{capitalize value}}
+            </div>
+
+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/capitalize.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/capitalize.js new file mode 100644 index 00000000..e2b5133f --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/capitalize.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "my first post" + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/center.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/center.hbs new file mode 100644 index 00000000..f27b4685 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/center.hbs @@ -0,0 +1,42 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Center | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

center Helper

+
+

Center the value in a field of a given width.

+ +
+
+
\{{center <value> <size=size> [pad=" "]}}
+
+

value - string to center

+

size - size of the final string

+

pad - string to be used as padding

+
+ +
+

Example

+
+
+            <div>
+                "\{{center value size=size}}"
+            </div>
+
+

when used with this context:

+
+
+                {
+                    value: "handlebars.java"
+                }
+
+

will result in:

+
+
+            <div>
+                "{{center value size=size}}"
+            </div>
+
+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/center.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/center.js new file mode 100644 index 00000000..822bf416 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/center.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "handlebars.java", + size: 19 + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/cut.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/cut.hbs new file mode 100644 index 00000000..c0262617 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/cut.hbs @@ -0,0 +1,42 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Cut | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

cut Helper

+
+

Remove all values of arg from the given string.

+ +
+
+
\{{cut value [" "]}}
+
+

value - string to be processed

+

arg - string which should be removed from the value string

+
+ +
+

Example

+
+
+            <div>
+                \{{cut value}}
+            </div>
+
+

when used with this context:

+
+
+                {
+                    value: "String with spaces"
+                }
+
+

will result in:

+
+
+            <div>
+                {{cut value}}
+            </div>
+
+
+{{/fillZone}} + diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/cut.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/cut.js new file mode 100644 index 00000000..6e6f5112 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/cut.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "String with spaces" + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/date-format.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/date-format.hbs new file mode 100644 index 00000000..40eb240d --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/date-format.hbs @@ -0,0 +1,27 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Date Format | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

dateFormat Helper

+
+

Formats the given date.

+ +
+
+
\{{dateFormat <date> ["format"] [format="format"][tz=timeZone|timeZoneId]}}
+
+

date - date to be formatted

+ +

You can format date using one of the following format parameters:

+ + Otherwise, the default formatter will be used. The format option can be specified as a parameter or hash (a.k.a + named parameter). +
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/default-if-empty.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/default-if-empty.hbs new file mode 100644 index 00000000..e32384ac --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/default-if-empty.hbs @@ -0,0 +1,42 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Default If Empty | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

defaultIfEmpty Helper

+
+

Assign a default value to a string if the string is evaluated as false.

+ +
+
+
\{{defaultIfEmpty <value> [default=""]}}
+
+

value - string to be evaluated

+

arg - default value

+
+ +
+

Example

+
+
+            <div>
+                \{{defaultIfEmpty value default}}
+            </div>
+
+

when used with this context:

+
+
+                {
+                    value: "",
+                    default: "nothing"
+                }
+
+

will result in:

+
+
+            <div>
+                {{defaultIfEmpty value default}}
+            </div>
+
+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/default-if-empty.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/default-if-empty.js new file mode 100644 index 00000000..76b63365 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/default-if-empty.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "", + default: "nothing" + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/index.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/index.hbs new file mode 100644 index 00000000..cfba011c --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/index.hbs @@ -0,0 +1,30 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "String Helpers | " @config.appName}} + +{{#fillZone "content"}} +

String Helpers

+
+ +{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/join.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/join.hbs new file mode 100644 index 00000000..8d28a79f --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/join.hbs @@ -0,0 +1,44 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Join | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

join Helper

+
+

Joins an array, iterator or an iterable with a string.

+ +
+
+
\{{join <value> <separator> [prefix=""] [suffix=""]}}
+
+

value - items to be concatenated (space separated values)

+

separator - item separator string

+
+ +
+

Example

+
+
+            <div>
+                \{{join a b c separator}}
+            </div>
+
+

when used with this context:

+
+
+                {
+                    a: "a",
+                    b: "b",
+                    c: "c",
+                    separator: " // "
+                }
+
+

will result in:

+
+
+            <div>
+                {{join a b c separator}}
+            </div>
+
+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/join.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/join.js new file mode 100644 index 00000000..d26ee975 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/join.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + a: "a", + b: "b", + c: "c", + separator: " // " + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/ljust.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/ljust.hbs new file mode 100644 index 00000000..04d38f79 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/ljust.hbs @@ -0,0 +1,42 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "LJust | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

ljust Helper

+
+

Left align the value in a field of a given width.

+ +
+
+
\{{ljust <value> <size=size> [pad=" "]}}
+
+

value - string to be aligned

+

size - size of the final string

+
+ +
+

Example

+
+
+            <div>
+                "\{{ljust value size=size}}"
+            </div>
+
+

when used with this context:

+
+
+                {
+                    value: "Handlebars.java",
+                    size: 20
+                }
+
+

will result in:

+
+
+            <div>
+                "{{ljust value size=size}}"
+            </div>
+
+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/ljust.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/ljust.js new file mode 100644 index 00000000..01fb04c2 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/ljust.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "Handlebars.java", + size: 20 + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/lower.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/lower.hbs new file mode 100644 index 00000000..09793bf4 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/lower.hbs @@ -0,0 +1,40 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Lower | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

lower Helper

+
+

Convert a string to lowercase.

+ +
+
+
\{{lower <value>}}
+
+

value - string to be converted

+
+ +
+

Example

+
+
+            <div>
+                \{{lower value}}
+            </div>
+
+

when used with this context:

+
+
+                {
+                    value: "HELLO"
+                }
+
+

will result in:

+
+
+            <div>
+                {{lower value}}
+            </div>
+
+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/lower.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/lower.js new file mode 100644 index 00000000..a6f1cfef --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/lower.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "HELLO" + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/now.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/now.hbs new file mode 100644 index 00000000..3f279c8f --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/now.hbs @@ -0,0 +1,25 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Now | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

now Helper

+
+

Add the current date.

+ +
+
+
\{{now ["format"] [tz=timeZone|timeZoneId]}}
+
+ +

Format parameters is one of:

+ +

Otherwise, the default formatter will be used.

+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/number-format.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/number-format.hbs new file mode 100644 index 00000000..3aa383d2 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/number-format.hbs @@ -0,0 +1,43 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Number Format | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

numberFormat Helper

+
+

Add the current date.

+ +
+
+
\{{numberFormat value ["format"] [format="format"][tz=timeZone|timeZoneId]}}
+
+

value - number to be formatted

+ +

Format parameters is one of:

+ +

Otherwise, the default formatter will be used.

+

More options

+ +
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/replace.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/replace.hbs new file mode 100644 index 00000000..3f2affe9 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/replace.hbs @@ -0,0 +1,45 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Replace | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

replace Helper

+
+

Replaces each substring of this string that matches the literal target sequence with the specified literal + replacement sequence.

+ +
+
+
\{{replace <value> <target> <replacement>}}
+
+

value - string to be processed

+

target - target string to be removed

+

replacement - replacement string for the target string

+
+ +
+

Example

+
+
+            <div>
+                \{{replace value target replacement}}
+            </div>
+
+

when used with this context:

+
+
+                {
+                    value: "Handlebars ...",
+                    target: "...",
+                    replacement: "rocks"
+                }
+
+

will result in:

+
+
+            <div>
+                {{replace value target replacement}}
+            </div>
+
+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/replace.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/replace.js new file mode 100644 index 00000000..16959f47 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/replace.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "Handlebars ...", + target: "...", + replacement: "rocks" + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/rjust.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/rjust.hbs new file mode 100644 index 00000000..e32ac594 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/rjust.hbs @@ -0,0 +1,42 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Rjust | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

rjust Helper

+
+

Right align the value in a field of a given width.

+ +
+
+
\{{rjust <value> <size=size> [pad=" "]}}
+
+

value - string to be aligned

+

size - size of the final string

+
+ +
+

Example

+
+
+            <div>
+                "\{{rjust value size=size}}"
+            </div>
+
+

when used with this context:

+
+
+                {
+                    value: "Handlebars.java",
+                    size: 20
+                }
+
+

will result in:

+
+
+            <div>
+                "{{rjust value size=size}}"
+            </div>
+
+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/rjust.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/rjust.js new file mode 100644 index 00000000..01fb04c2 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/rjust.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "Handlebars.java", + size: 20 + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/slugify.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/slugify.hbs new file mode 100644 index 00000000..9e70a337 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/slugify.hbs @@ -0,0 +1,41 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Slugify | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

slugify Helper

+
+

Converts a value to lowercase, remove non-word characters (alphanumerics and underscores) and convert + spaces to hyphens. Also strip leading and trailing whitespace.

+ +
+
+
\{{slugify <value>}}
+
+

value - string to be processed

+
+ +
+

Example

+
+
+            <div>
+                \{{slugify value}}
+            </div>
+
+

when used with this context:

+
+
+                {
+                    value: "Joel is a slug"
+                }
+
+

will result in:

+
+
+            <div>
+                {{slugify value}}
+            </div>
+
+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/slugify.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/slugify.js new file mode 100644 index 00000000..754d7dd1 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/slugify.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "Joel is a slug" + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/string-format.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/string-format.hbs new file mode 100644 index 00000000..4193e95d --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/string-format.hbs @@ -0,0 +1,42 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "String Format | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

stringFormat Helper

+
+

Formats the variable according to a string formatting specifier.

+ +
+
+
\{{stringFormat value <params>...}}
+
+

value - formatting specifier

+

params - list of parameters

+
+ +
+

Example

+
+
+            <div>
+                \{{stringFormat value param}}
+            </div>
+
+

when used with this context:

+
+
+                {
+                    value: "Hello %s",
+                    param: "handlebars.java"
+                }
+
+

will result in:

+
+
+            <div>
+                {{stringFormat value param}}
+            </div>
+
+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/string-format.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/string-format.js new file mode 100644 index 00000000..f6c64f7f --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/string-format.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "Hello %s", + param: "handlebars.java" + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/strip-tags.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/strip-tags.hbs new file mode 100644 index 00000000..20d43553 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/strip-tags.hbs @@ -0,0 +1,16 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Strip Tags | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

stripTags Helper

+
+

Strips HTML tags.

+ +
+
+
\{{stripTags <value>}}
+
+

value - string to be processed

+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/substring.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/substring.hbs new file mode 100644 index 00000000..14ce4513 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/substring.hbs @@ -0,0 +1,70 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Substring | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

substring Helper

+
+

Get a character sequence that is sub sequence of the given sequence. The sub sequence starts with the character + value at the specified index and ends with the character value at the index end-1.

+ +
+
+
\{{substring <value> <start> [end=STRING_LENGTH]}}
+
+

value - string to be processed

+

start - start offset

+

end - end offset

+
+ +
+

Example 1

+
+
+            <div>
+                \{{substring value start1}}
+            </div>
+
+

when used with this context:

+
+
+                {
+                    value: "Handlebars.java",
+                    start1: 11
+                }
+
+

will result in:

+
+
+            <div>
+                {{substring value start1}}
+            </div>
+
+
+ +
+

Example 2

+
+
+            <div>
+                \{{substring value start2 end2}}
+            </div>
+
+

when used with this context:

+
+
+                {
+                    value: "Handlebars.java",
+                    start2: 0,
+                    end2: 10
+                }
+
+

will result in:

+
+
+            <div>
+                {{substring value start2 end2}}
+            </div>
+
+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/substring.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/substring.js new file mode 100644 index 00000000..6b62df43 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/substring.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "Handlebars.java", + start1: 11, + start2: 0, + end2: 10 + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/upper.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/upper.hbs new file mode 100644 index 00000000..dfecb704 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/upper.hbs @@ -0,0 +1,40 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Upper | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

lower Helper

+
+

Convert a string to uppercase.

+ +
+
+
\{{upper <value>}}
+
+

value - string to be converted

+
+ +
+

Example

+
+
+            <div>
+                \{{upper value}}
+            </div>
+
+

when used with this context:

+
+
+                {
+                    value: "Hello"
+                }
+
+

will result in:

+
+
+            <div>
+                {{upper value}}
+            </div>
+
+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/upper.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/upper.js new file mode 100644 index 00000000..1e1e2003 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/upper.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "Hello" + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/word-wrap.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/word-wrap.hbs new file mode 100644 index 00000000..1de591f6 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/word-wrap.hbs @@ -0,0 +1,38 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Word Wrap | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

wordWrap Helper

+
+

Wraps words at specified line length.

+ +
+
+
 \{{wordWrap <value> <size>}}
+
+

value - string to be wrapped

+

size - number of characters at which to wrap the text

+
+ +
+

Example

+
+
+                \{{wordWrap value size}}
+
+

when used with this context:

+
+
+                {
+                    value: "Joel is a slug",
+                    size: 5
+                }
+
+

will result in:

+
+
+{{wordWrap value size}}
+
+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/word-wrap.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/word-wrap.js new file mode 100644 index 00000000..11ea2f8a --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/word-wrap.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "Joel is a slug", + size: 5 + }; +} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/yesno.hbs b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/yesno.hbs new file mode 100644 index 00000000..38ef3e9f --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/yesno.hbs @@ -0,0 +1,16 @@ +{{layout "org.wso2.carbon.uuf.sample.foundation.main"}} +{{title "Yes No | String Helper Sample | " @config.appName}} +{{fragment "org.wso2.carbon.uuf.sample.foundation.highlight" theme=@config.highlightjsTheme}} + +{{#fillZone "content"}} +

yesno Helper

+
+

Map values for true, false and (optionally) null, to the strings "yes", "no", "maybe".

+ +
+
+
\{{yesno <value> [yes="yes"] [no="no"] maybe=["maybe"]}}
+
+

value - string to be mapped

+
+{{/fillZone}} diff --git a/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/yesno.js b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/yesno.js new file mode 100644 index 00000000..9b5e2f57 --- /dev/null +++ b/samples/apps/org.wso2.carbon.uuf.sample.features-app/src/main/pages/helpers/string-helpers/yesno.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function onRequest(env) { + return { + value: "yes" + }; +}