-
Notifications
You must be signed in to change notification settings - Fork 93
DRYML
There is a good up to date DRYML Guide here PDF
The Hobo Cookbook has a very nice tag reference.
Hobo automatically generates views but as apps get more complex the developers will need to customize the views. This is an attempt to explain how DRYML works.
Types of views: (this example assumes a “project” model and controller)
- show.dryml – Show a single record for example http://localhost:3000/projects/3-userwiki
- index.dryml – Index shows all the records – http://localhost:3000/projects
- edit.dryml – Edit page for editing a single record – http://localhost:3000/projects/3/edit
- new.dryml – New page for adding a record to a table – http://localhost:3000/projects/1/edit
- _<partial>.dryml – Partial page for ajax page updates
What do the automatically generated dryml templates look like?
<def tag="index-page" for="Project">
<page merge title="Projects">
<body: class="index-page project" param/>
<content: param>
<header param="content-header">
<h2 param="heading">Projects</h2>
<p param="count" if>There <count prefix="are"/></p>
</header>
<section param="content-body">
<a action="new" to="&model" merge-params/>
<page-nav param="top-page-nav"/>
<collection param/>
<page-nav param="bottom-page-nav"/>
</section>
</content:>
</page>
</def>
If you have Hobo 0.80 you can see these automatically generated templates in /app/views/taglibs/auto/rapid
Directory of D:\workspace\Agility\app\views\taglibs\auto\rapid
D:\workspace\Agility\app\views\taglibs\auto\rapid>dir Volume in drive D is DATA Volume Serial Number is 1440-4E18
10/13/2008 11:16 AM 1,473 cards.dryml
10/13/2008 11:16 AM 4,007 forms.dryml
10/13/2008 11:16 AM 17,757 pages.dryml
3 File(s) 23,237 bytes
D:\workspace\Agility\app\views\taglibs\auto\rapid>
DRYML makes it easy to override just the parts of the view that you want to.
Example: to override the index page for the project controller create an index.dryml file in:
D:\workspace\Agility\app\views\projects\index.dryml
or generically
D:\workspace\Agility\app\views\<model-name>s\index.dryml
Might look like this:
<index-page>
<content-body:>
this is where you could replace the standard body with your own stuff
the index-page tag recalls the automatically generated
index for the model, project in this case
the param attribute in the automatically generated template
indicates which parts can be overridden
</content-body:>
</index-page>
There is a lot of good dryml instruction in the Agility Tutorial.
When pulling up the index for the entire site no model is specified
http://localhost:3000/
so the location of custom DRYML templates is placed in a subfolder called front
D:\workspace\Agility\app\views\front\index.dryml