2007/5/24, Oleg Kobchenko <[EMAIL PROTECTED]>: [snip]
require 'web/jhp' v=: 3 : 0 r=: '' print=: 3 : 'r=: r,padj y' 3 : (hrep y)'' r ) name=: 'JHP' v 'Hello <%=name%>!' Hello JHP! v 'Hello <%=i.3 4%>!' Hello 0 1 2 3 4 5 6 7 8 9 10 11!
Here is a nested template example: require 'web/jhp' v=: 3 : 0 r=: '' print=: 3 : '''''[r=: r,padj y' println=: 3 : '''''[r=: r,LF,~ padj y' 3 : (hrep y)'' r ) male=: monad hdef 'Mr. <%= y%>' person=: 'Joe' v 'Hello, <%=male person%>!' Hello, Mr. Joe! Maybe, using locales is better?
--- June Kim <[EMAIL PROTECTED]> wrote: > Hi, > > I've been playing with JHP recently. While it does well what it > originally attempts to do, I'd like to extend and generalize its use. > I want to use it for general templating. > > The first step could be letting JHP return a result string. However, > the code isn't particularly designed for extension. (I have to copy > and modify the code directly) > > template=: 'hello Mr./Mrs. <%= name %>' > name=:'Jane' > hrep template > print 'hello Mr./Mrs. ' > print name > 0!:0 hrep template NB. since this session is from J window print > is smoutput > hello Mr./Mrs. > Jane > > What I want is a verb v that does: > > 'hello Mr./Mr.s Jane' -: v template > > I could modify the code directly myself, but that doesn't seem like a > proper way of extending a code. Code should be closed for modification > but open for extension[1]. > > Obviously, next step would be handing over a key, value pairs(maybe > the name of a locale that contains those variables) to the templating > verb. > > > [1] Open-Closed principle http://www.objectmentor.com/resources/articles/ocp.pdf > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ____________________________________________________________________________________ Never miss an email again! Yahoo! Toolbar alerts you the instant new Mail arrives. http://tools.search.yahoo.com/toolbar/features/mail/ ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
