Hi, everyone. I’m new to Radiant, developing my first Radiant-powered
site.
I’ve developed a preview extension, which injects via javascript a
preview
link into the page editor, which when clicked hides the textbox and
shows a
div filled with the preview (obtained through Ajax.Updater). To
accomplish
this, I have a controller method which takes the raw text from the
textbox
and returns rendered html. My problem is, while my method works fine for
built-in radius tags, it does not work for radius tags defined in
extensions. My code is below.
def filter_text(filter, text, slug)
filterClass = nil
eval(“filterClass = #{filter}Filter”)
filter = filterClass.new
filteredText = filter.filter(text)
page = Page.find(:first, :conditions => [“slug = ?”, slug])
context = PageContext.new(page)
parser = Radius::Parser.new(context, :tag_prefix => ‘r’)
begin
return parser.parse(filteredText);
rescue
return filteredText
end
end
I admit that I don’t really have much of an idea of what I’m doing here.
I’ve been looking through the code of Radiant trying to figure out how
it
does it, but I’ve been unable to find the place where it actually does
the
rendering (I assume it’s somewhere in the Page model, but the only
radius
code I’ve been able to find there I’ve replicated above). Any help would
be
greatly appreciated.