|
Custom Macros The way we filled the MySQL database with some data is quite unefficient. Why not do it with Helma? <a href="mailto:<% this.email %>"><% this.firstname %> <% this.lastname %></a> <small><a href="<% this.href action="edit" %>">edit</a></small><br />Other than the first three macros, this.href does not refer to a property of a person HopObject. It is a custom macro that needs a macro handler, ie. a function to work: apps/addressbook/Person/macros.js: function href_macro(param) {
return(this.href() + param.action);
}
Enter the above lines in a new file and save this as macros.js in the Person directory.Now let's put it altogether: Helma transforms the macro structure <% this.href action="edit" %> into a function call of this.href_macro(param) with param being a generic object containing the property action (along with its value). That means param.action contains the string "edit" as it was assigned in the macro structure. The function href_macro(param) then returns the URL of the actual person HopObject plus "edit". A look at the browser will proove if these considerations are right: Hannes Wallnöfer edit Robert Gaggl edit Tobi Schäfer edit Great! It works. But yet the links lead into Helmatic nirvana. We have to enable the edit form, first.
... comment
klemens,
Wednesday, 30. April 2008, 15:48
would prefer:
function href_macro(param) { return(this.href(param.action)); } ... link ... comment |
navigation
Download
Community
Weblog
Mailing Lists
IRC Channel
Documentation
Introductions
Tools
Reference
Project
Roadmap
Bug Reporting
Source
Wiki
Tags
Updates
Related Projects
search
|
||||