I will be putting Jeff Smick's binding of libxml2 into the
distribution at some point.
--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=.
{
'#example': {
h2: 'My updated title',
p: 'My content',
'.foo': gerSomeDataByScripting()
}
}
dom.select('#example').each(function(ele) {
ele.select('h2').text("My updated title");
ele.select(p').text("My content");
ele. select('.foo').html(gerSomeDataByScripting());
});
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
My personal preference is:
http://json-template.googlecode.com/svn/trunk/doc/Introducing-JSON-Template.html
> --
>
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=.
Regarding the earlier suggestion of putting a DOM parser in Nodejs: I
think that's not a good idea. It would be best to build this kind of
parser as an extension (or simply a JS library) and provide it as a
node add-on that people could either use or ignore. I personally
favor having lots of choice over having to settle on a definition of
"ideal", and it would be a shame to burden the nodejs core with
something that one might never use.
--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
<table>
<tr>
<td>[myblock.name;block=tr]</td>
<td>[myblock.text]</td>
</tr>
</table>
merging rows of a table is as simple as calling
mergeBlock('myblock', [{name:'n1', text:'text1'}, {name:'n2', text:'text2'}])
Display is controlled via 'magnet' and 'bmagnet' params.
Some logic is available :
<div><p>[myField;if [val]='toto';then 'Hello';else '']</p></div>
and so on... The manual is complete and examples are provided.
TBS is a php template engine, but portable in other languages, since it really
is just string manipulations.
Jérémy.
> <mailto:nod...@googlegroups.com>.
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> <mailto:nodejs%2Bunsu...@googlegroups.com>.
tbs is not a really good idea as it is, i agree. It went quite wrong nowadays.
Still :
- there is something nice with defining in the view which parts to repeat when merging "tables".
That way, the controller does not have to know where the data to be merged should be in the
template.
- blocks of data to repeat don't need a beginblock - endblock, so it's still readable before merge
I won't troll any more :)
Jérémy.
On Nov 21, 7:43 am, Tero Piirainen <tipii...@gmail.com> wrote:
> First: I'm really impressed with nodejs. Thank you guys! This will
> change the world. Now that we have a fresh start for an ideal server
> side framework I'm proposing here a syntax for an idealtemplate
> language. Here is an example
>
> <!-- html "template" -->
> <div id="example">
> <h2>Title</h2>
>
> <p>Something here</p>
>
> <p class="foo"></p>
>
> </div>
>
> And here is the JS that will make dynamic changes to thetemplate
>
> // the JavaScript
> {
> '#example': {
> h2: 'My updated title',
> p: 'My content',
> '.foo': gerSomeDataByScripting()
> }
>
> }
>
> So what is so special about this
>
> 1. thetemplateis pure HTML no special markers ortemplatesyntax
For example, an 'add comment to blog' feature could either a) update
the page inline with ajax or b) reload the page from the server.
Either way we want it to produce an identical result (minus any
javascript based animation effects). What I've come up with so far is
the concept of data binding. The template language is heavily inspired
by json-template, but links all the template language commands to a
javascript binding object. This binding acts as a layer between the
controller code and the view, allowing the view to be dynamically
updated (inline for client side, completely rendered for server side).
For example:
//controller action that sends its result back to a framework level
event handler
//this case is called on form submit for the 'add comment' form
data = ...some data returned from a database callback query...;
page_binding = templates.template_name.bind(data)
new_comment = ...load some data from the form, make a new Comment
object...
if (new_data.is_valid())
page_binding.comments.push(new_comment) //add the new comment to
the page
else
page_binding.new_comment.errors = new_data.validation_errors() //
show the errors on the page
return page_binding
//framework level - processes the result of the above controller
action:
//server side:
http_response.send(page_binding.render()) //full page render, send
back html
//client side:
page_binding.update() //DOM manipulation with possible animations and
such
The key point is that the controller is identical server side and
client side. The framework is just a thin layer that provides a
uniform base for the server/client side - so that controllers don't
have to care where they're running. The page binding 'render' would
render a full template, whereas the 'update' function would be able to
render just the 'comment' sub-template, make a dom node for it, and
append it to the right parent in the DOM.
At any rate, I've got a decent portion of this done and working, and
will post once I'm finished. Thoughts/suggestions welcome.
On Nov 23 2009, 6:07 am, Simon Willison <si...@simonwillison.net>
On Jan 15, 7:16 am, "Jérémy Lal" <holi...@gmail.com> wrote:
> i second that !
> it should also support plain text files the same way (eg csv files),
> so should not rely upon an xml or html parser...
If that's your requirement, then JSON Template should fit well:
http://code.google.com/p/json-template/
PURE is HTML + JSON = HTML
JSON Template is template + JSON = arbitrary text.
That is, it doesn't know anything HTML. I've used it for generating
code from an AST, batch files, etc.
Andy
On Nov 23 2009, 1:15 pm, Hagen <six...@gmail.com> wrote:
> Hpricot is cool. The only reason I suggested webkit's is the existing
> integration of that parser and v8 somewhere available in chrome.
>
> Otoh, having a DOM would make integrating server-side and client-side code
> even more trivial. E.g. an implementation of the template engine spawning
> this thread could reuse jQuery code for selecting the correct node.
>
>
>
> On Mon, Nov 23, 2009 at 11:09 AM, Ryan Dahl <coldredle...@gmail.com> wrote:
> > On Mon, Nov 23, 2009 at 11:04 AM, Hagen <six...@gmail.com> wrote:
> > >> I will be putting Jeff Smick's binding of libxml2 into the
> > >> distribution at some point.
>
> > > Please correct me if I am wrong, but libxml2 does not have an HTML mode.
> > > Having libxml2 is cool and all, but having a true HTML parser is a whole
> > > different beast. Believe me, I tried implementing a web crawler, parsing
> > > HTML is a royal pain if you don't have access to a browser's parser.
>
> > Sounds like a reasonable feature to have. Maybe using _why's parser
> > from Hpricot is better / less entangled than webkit.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "nodejs" group.
> > To post to this group, send email to nod...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > nodejs+un...@googlegroups.com<nodejs%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nodejs?hl=.
>
> --
> Dissertations are a successful walk through a minefield -- summarizing them
> is not. - Roy Fielding
Example (from the aforementioned URL):
<%inherit file="base.html"/>
<%
rows = [[v for v in range(0,10)] for row in range(0,10)]
%>
<table>
% for row in rows:
${makerow(row)}
% endfor
</table>
<%def name="makerow(row)">
<tr>
% for name in row:
<td>${name}</td>\
% endfor
</tr>
</%def>
...
Would be neat to have that in node/javacsript, although I've
personally stopped believing in server-side templating (since web
browsers do this now days and it's called HTML ;). However still nice
for things like CSV, Atom, RSS, etc.
> --
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
>
>
>
>
--
Rasmus Andersson
--
Rasmus Andersson
Once we have a package manager working, I'm sure it will be very easy to pick one of a number of templating systems that folks will package for node.
cheers
O
+1
Naturally there will exist many different templating modules. Not
something usually found in a standard library either.
http://github.com/gmosx/normal-template
It replaces the 'cursor' model of JSON-Template with (a subset of)
XPath and provides an optional meta-templating mechanism.
-g.