On Sat, Jul 07, 2012 at 01:38:42PM -0400, Alan Gutierrez wrote:
> On Sat, Jul 07, 2012 at 10:55:26AM -0300, Angel Java Lopez wrote:
> > Thanks!
> >
> > I usually do in your suggested way, and I'm with you. But in this special
> > case, I feel the user of my module could find a bit weird to write
> >
> > var st = require('simpletags');
> >
> > st.html(st.head(st.title('...')), st.body(st.h1(....))
> >
> > instead
> >
> > html(head(title('....')), body(h1('...'))
> >
> > in a controlled way (only in its own module). I want to give him/her an
> > option. Ruby has it (as an option, too). It's the first time I found I
> > needed it in Node.js. Usually, I assert "Ruby ceremony > Javascript/Node.js
> > ceremony", but now, I was trapped by this issue.
> >
> > My best solutions:
> >
> > a)
> > var st = require(...); // and use with st.h1, st.h2...
> >
> > b)
> > require('simpletags').exportsTo(global); // maybe in browser I could export
> > to windows directly in the module
> >
> > c)
> > var simpletags = require('simpletags');
> > eval(simpletags.exportLocalCode()); // where .exportLocalCode returns a
> > String with "var h1 = simpletags.h1; ... "
> > c2)
> > var st = require('simpletags');
> > eval(st.exportLocalCode('st')); // the local variable name 'st' should be
> > informed to be used in var ...= .... string result
>
> also:
>
> require('simpletags')(function (tags) {
> with (tags) {
> html(head(title('....')), body(h1('...'));
> }
> });
Or rather:
with (require('simpletags')) {
html(head(title('....')), body(h1('...'));
}
Will not work with `"use strict"`.
https://twitter.com/brendaneich/status/68001466471817216
Not sure how noders feel about that.
--
Alan Gutierrez - http://github.com/bigeasy - http://twitter.com/bigeasy
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en