[webgen-users] writing a custom Tag class

5 views
Skip to first unread message

Thomas Danckaert

unread,
Dec 21, 2009, 5:33:05 AM12/21/09
to webgen...@rubyforge.org
Hi,

I'm trying to understand webgen's inner workings a little, so I can
extend it myself. I thought writing a new Tag class would be a good
place to start, but I'm already running into problems...

I'm trying to use the example "Reverser" class from the rdocs on
Tag::Base. I thought I just needed to copy the code from the sample
tag class to the init.rb file of a webgen site, and then add some
"{reverse: Reverse this string}" tag to a page file to see it work.
However, I get the following error when I do this:

"undefined local variable or method `default' for main:Object"

The line of code causing this problem is
Webgen::WebsiteAccess.website.config.reverser.do_reverse
nil, :mandatory => default
Am I correct in that this should be
Webgen::WebsiteAccess.website.config.reverser.do_reverse
(nil, :mandatory => 'default')
? When I make this change, I get the new error:

"Error while rendering </testtag.en.html>:
No such configuration option: do_reverse"
>From here on, I don't know what to do...

Also, I'm afraid I don't really understand what the "body" in the tag
class method call(tag, body, context) is. If I have a tag {mytag:
{someparam: somevalue, otherparam: othervalue}} in the file "/
index.page", what is the "body" given to the call method?

Obviously I'm still in the stage of complete confusion. Any help would
be greatly appreciated!

Thomas
_______________________________________________
webgen-users mailing list
webgen...@rubyforge.org
http://rubyforge.org/mailman/listinfo/webgen-users

Thomas Deselaers

unread,
Dec 21, 2009, 5:35:52 AM12/21/09
to webgen...@rubyforge.org
Hi Thomas (there is quite an amount of Thomasses on this list),

I recently was at the same spot as you are and worked my way through
webgens sourcecode.

I guess, my overlib example is about the most simple example you can do:

Find details in the emails to this list:

http://groups.google.com/group/webgen-users/browse_thread/thread/cbee5502d1fd0b08


cheers,
thomas

--
http://thomas.deselaers.de

Thomas Leitner

unread,
Dec 21, 2009, 11:15:29 AM12/21/09
to webgen...@rubyforge.org
> The line of code causing this problem is
> Webgen::WebsiteAccess.website.config.reverser.do_reverse
> nil, :mandatory => default
> Am I correct in that this should be
> Webgen::WebsiteAccess.website.config.reverser.do_reverse
> (nil, :mandatory => 'default')

Yes, this is a bug in the documentation. Is already fixed in the repo
and the fix will go live with the next release.

> ? When I make this change, I get the new error:
>
> "Error while rendering </testtag.en.html>:
> No such configuration option: do_reverse"
> >>From here on, I don't know what to do...

Can you provide your ext/init.rb file sothat I can investigate?



> Also, I'm afraid I don't really understand what the "body" in the tag
> class method call(tag, body, context) is. If I have a tag {mytag:
> {someparam: somevalue, otherparam: othervalue}} in the file "/
> index.page", what is the "body" given to the call method?

webgen 0.5 allows you to use a body with a tag. Have a look at
http://webgen.rubyforge.org/documentation/contentprocessor/tags.html
and http://webgen.rubyforge.org/documentation/tag/coderay.html for more
information.

-- Thomas

Reply all
Reply to author
Forward
0 new messages