r9738 - in helma-ng/trunk/apps/demo: . skins
[email protected] Wed, 13 May 2009 14:52:23 +0200 (CEST)
| Newsgroups | gmane.comp.java.helma.cvs |
|---|---|
| Message-ID | <20090513125223.54A8A3D0D6@mia> |
Author: hannes
Date: 2009-05-13 14:52:23 +0200 (Wed, 13 May 2009)
New Revision: 9738
Added:
helma-ng/trunk/apps/demo/skins/continuation.txt
helma-ng/trunk/apps/demo/skins/logging.txt
helma-ng/trunk/apps/demo/skins/modules.txt
Removed:
helma-ng/trunk/apps/demo/skins/continuation.html
helma-ng/trunk/apps/demo/skins/logging.html
helma-ng/trunk/apps/demo/skins/modules.html
helma-ng/trunk/apps/demo/skins/profiler.html
Modified:
helma-ng/trunk/apps/demo/actions.js
helma-ng/trunk/apps/demo/skins/skins.txt
helma-ng/trunk/apps/demo/webmodule.js
Log:
Spruce up demo app content for 0.3 release.
Details at http://dev.helma.org/trac/helma/changeset/9738
Modified: helma-ng/trunk/apps/demo/actions.js
===================================================================
--- helma-ng/trunk/apps/demo/actions.js 2009-05-13 09:50:47 UTC (rev 9737)
+++ helma-ng/trunk/apps/demo/actions.js 2009-05-13 12:52:23 UTC (rev 9738)
@@ -36,8 +36,16 @@
} catch (e) {
log.error(e, e.rhinoException);
}
+ } else if (req.params.profile) {
+ var profiler = require('helma/profiler');
+ req.process = function() {
+ return SkinnedResponse('skins/logging.txt', {
+ title: "Logging & Profiling"
+ });
+ }
+ return profiler.handleRequest(req);
}
- return new SkinnedResponse('skins/logging.html', { title: "Logging" });
+ return new SkinnedResponse('skins/logging.txt', { title: "Logging & Profiling" });
}
// demo for continuation support
@@ -49,13 +57,13 @@
req = session.start();
// render intro page
- req = session.step(1).render(SkinnedResponse('skins/continuation.html', {
+ req = session.step(1).render(SkinnedResponse('skins/continuation.txt', {
session: session,
title: "Continuations",
data: data
}));
- req = session.step(2).render(SkinnedResponse('skins/continuation.html', {
+ req = session.step(2).render(SkinnedResponse('skins/continuation.txt', {
session: session,
title: "Question 1",
data: data
@@ -63,7 +71,7 @@
if (req.isPost)
data.name = req.params.name;
- req = session.step(3).render(SkinnedResponse('skins/continuation.html', {
+ req = session.step(3).render(SkinnedResponse('skins/continuation.txt', {
session: session,
title: "Question 2",
data: data
@@ -71,7 +79,7 @@
if (req.isPost)
data.food = req.params.food;
- req = session.step(4).render(SkinnedResponse('skins/continuation.html', {
+ req = session.step(4).render(SkinnedResponse('skins/continuation.txt', {
session: session,
title: "Question 3",
data: data
@@ -79,19 +87,9 @@
if (req.isPost)
data.animal = req.params.animal;
- session.step(5).render(SkinnedResponse('skins/continuation.html', {
+ session.step(5).render(SkinnedResponse('skins/continuation.txt', {
session: session,
title: "Thank you!",
data: data
}));
}
-
-function profiler(req) {
- var profiler = require('helma/profiler');
- req.process = function() {
- return SkinnedResponse('skins/profiler.html', {
- title: "Profiler"
- });
- }
- return profiler.handleRequest(req);
-}
\ No newline at end of file
Deleted: helma-ng/trunk/apps/demo/skins/continuation.html
Copied: helma-ng/trunk/apps/demo/skins/continuation.txt (from rev 9737, helma-ng/trunk/apps/demo/skins/continuation.html)
Deleted: helma-ng/trunk/apps/demo/skins/logging.html
Added: helma-ng/trunk/apps/demo/skins/logging.txt
Deleted: helma-ng/trunk/apps/demo/skins/modules.html
Added: helma-ng/trunk/apps/demo/skins/modules.txt
Property changes on: helma-ng/trunk/apps/demo/skins/modules.txt
___________________________________________________________________
Name: svn:executable
+ *
Deleted: helma-ng/trunk/apps/demo/skins/profiler.html
Modified: helma-ng/trunk/apps/demo/skins/skins.txt
===================================================================
--- helma-ng/trunk/apps/demo/skins/skins.txt 2009-05-13 09:50:47 UTC (rev 9737)
+++ helma-ng/trunk/apps/demo/skins/skins.txt 2009-05-13 12:52:23 UTC (rev 9738)
@@ -1,68 +1,70 @@
<% extends 'base.html' %>
<% subskin 'content' | markdown %>
-This page showcases some of the skinning featuers in Helma NG, such as macros, subskins, and filters.
+The `helma/skin` module provides web application developers with a flexible templating framework.
+At its simplest, creating and rendering a skin looks like this:
-This is the action code that renders the skin:
+ helma> include('helma/skin');
+ helma> var skin = createSkin('Hello \<% name %>!');
+ helma> skin.render({ name: 'World' });
+ Hello World!
- function skins(req, res) {
- res.render('skins/skins.html', {
- title: 'Skin Demo',
- name: 'Luisa',
- names: ['Benni', 'Emma', 'Luca', 'Selma']
- });
- }
-
-And the following subskin in skins.html:
+The part wrapped in \<% %> is called macro tag in Helma NG. Macros are replaced at render time
+by looking for corresponding properties or functions in the context argument passed to `Skin.render()`.
+Helma also provides a number of built-in macros which are described below.
+### Subskins
+
+A very important feature are subskins, which are named skin fragments that work pretty much like functions work in
+JavaScript. A subskin is created using the builtin \<% subskin %> tag and ends with the begin of the
+next subskin or the skin end.
+
\<% subskin hello %>
Hello \<% name %>!</pre>
-Your basic skin rendering macro then looks like this:
+Use the built-in \<% render %> macro to render a subskin with the current context:
\<% render hello %>
-And this is the output this produces:
+Provided the `skin.render()` method is called with context argument
+`{name: 'Luisa'}` the output will be:
<p style="background-color: pink;"><% render hello %></p>
-The render macro also lets you loop through arrays and other iterables:
+You can also bind values to the macro context in the tag:
- \<% for name in \<% names %> render hello %>
+ \<% set {name: Julia} render hello %>
-This is what you should get:
-
<p style="background-color: pink;">
-<% for name in <% names %> render hello %>
+<% set {name: Julia } render hello %>
</p>
-You can also bind values to the macro context in the tag:
+### Loops
- \<% set {name: Julia} render hello %>
+The for..in macro gives you an easy way to loop through arrays and other objects that support
+for-in loops in JavaScript.
-This gets you
+ \<% for name in \<% names %> render hello %>
<p style="background-color: pink;">
-<% set {name: Julia } render hello %>
+<% for name in <% names %> render hello %>
</p>
Or you can define the objects to loop through using object and array literals in the macro tag:
\<% for name in [Gerlinde, Ralph, Thomas] render hello %>
-Produces:
-
<p style="background-color: pink;">
<% for name in [Gerlinde, Ralph, Thomas] render hello %>
</p>
+### Filters
+
Finally, [filters][ng:helma.filters] let you do all kinds of post-processing
on the output of a macro.
\<% render hello | uppercase %>
-Renders:
-
<p style="background-color: pink;">
<% render 'hello' | uppercase %>
</p>
Modified: helma-ng/trunk/apps/demo/webmodule.js
===================================================================
--- helma-ng/trunk/apps/demo/webmodule.js 2009-05-13 09:50:47 UTC (rev 9737)
+++ helma-ng/trunk/apps/demo/webmodule.js 2009-05-13 12:52:23 UTC (rev 9738)
@@ -8,5 +8,5 @@
title: 'Modules',
href: req.pathDecoded
};
- return new SkinnedResponse('skins/modules.html', context);
+ return new SkinnedResponse('skins/modules.txt', context);
}