EJS View Helpers in Express

936 views
Skip to first unread message

Jake Smith (jakefolio)

unread,
Dec 17, 2010, 12:22:52 PM12/17/10
to Express
I try to use a view helper in express, utilizing EJS, and I keep
getting the following error:
500 ReferenceError: input_field_tag is not defined

What do I need to do to make the view helpers usable?

// Configure App

app.configure(function(){
app.register('.html', require('ejs'));
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.set('view options', {
layout: 'layout.html'
});
app.use(express.bodyDecoder());
app.use(express.cookieDecoder());
app.use(express.session());
app.use(express.methodOverride());
app.use(express.compiler({ src: __dirname + '/public', enable:
['less'] }));
app.use(app.router);
});

tjholowaychuk

unread,
Dec 17, 2010, 12:27:28 PM12/17/10
to Express
on a side note you can drop layout: 'layout.html' since that is
implied by the register you did.

but what you need to do is call app.helpers({ input_field_tag:
function(){} })

which you can call several times, it should keep merging them in

On Dec 17, 9:22 am, "Jake Smith (jakefolio)" <jake.smit...@gmail.com>
wrote:

Jake Smith (jakefolio)

unread,
Dec 17, 2010, 1:15:09 PM12/17/10
to Express
That adds an empty helper, but EJS has already built in view helpers
which I get errors on.

- Jake

vision media [ Tj Holowaychuk ]

unread,
Dec 17, 2010, 1:53:04 PM12/17/10
to expre...@googlegroups.com
im not sure what you are talking about. Can you show me? which ejs library? if it is mine, then no there are no extra helpers, it works the same as any other template engine which supports Express, "helpers" are just locals that happen to be functions.

--
You received this message because you are subscribed to the Google Groups "Express" group.
To post to this group, send email to expre...@googlegroups.com.
To unsubscribe from this group, send email to express-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/express-js?hl=en.




--
Tj Holowaychuk
Vision Media
President & Creative Lead

Jake Smith (jakefolio)

unread,
Dec 18, 2010, 11:13:01 AM12/18/10
to Express
I'm trying to use these view helpers:
http://code.google.com/p/embeddedjavascript/wiki/ViewHelpers

Anytime I try to use them I get a reference error in express. Doing
what tjholowaychuk said to do just creates a blank helper and returns
undefined.

- Jake

On Dec 17, 12:53 pm, "vision media [ Tj Holowaychuk ]" <t...@vision-
> > express-js+...@googlegroups.com<express-js%2Bunsubscribe@googlegrou ps.com>
> > .

vision media [ Tj Holowaychuk ]

unread,
Dec 18, 2010, 4:23:59 PM12/18/10
to expre...@googlegroups.com
oh, that library sucks, if you use stuff like that IMO you might as well just not use a template engine at all really

To unsubscribe from this group, send email to express-js+...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/express-js?hl=en.

Reply all
Reply to author
Forward
0 new messages