Trying to get to grips with ERB, new to Webby

5 views
Skip to first unread message

Alex Muller

unread,
Oct 15, 2010, 2:49:11 PM10/15/10
to Webby
Hi all,

New to Webby and Ruby, and I'd appreciate any help you can give me
with ERB; this seems to be a great little tool for a project I'm
working on.

I'm editing my default.txt layout file and can't understand why this
is happening:

<%= @page.title %> returns "My Page Title"
<%= @content %> returns "My page content goes right in here"
<%= ((defined? @page.title) ? 'SET' : 'NOT SET') %> returns "NOT SET"
<%= ((defined? @content) ? 'SET' : 'NOT SET') %> returns "SET"

I'm trying to include a variable from the content metadata, but only
if it's set.

Hope that makes sense,

Alex

Magnus Holm

unread,
Oct 16, 2010, 8:57:10 AM10/16/10
to webby...@googlegroups.com
Webby uses method_missing, so defined? won't work here. Try checking !@page.title.nil? instead.
// Magnus Holm

Alex Muller

unread,
Oct 18, 2010, 4:09:31 AM10/18/10
to Webby
That's brilliant Magnus, thank you!

Much appreciated,

Alex

On Oct 16, 1:57 pm, Magnus Holm <judo...@gmail.com> wrote:
> Webby uses method_missing, so defined? won't work here. Try checking
> !...@page.title.nil? instead.
> // Magnus Holm
Reply all
Reply to author
Forward
0 new messages