I would like to generate Rules DSL from the helper module. I have custom blog helper and i would like it to generate RSS feeds automatically so I don't have to specify any compile and routing rules in the Rules
file as long as specific metadata is present.
So lets say I have my blog in news.erb
and news\*.md
directory. Erb file has blog configuration in its metadata section (number of articles to show, ordering etc..) In preprocessing I have create_blog
function which generates \page\N
depending on the metadata I have in news.erb
. If this metadata includes rss: true
section I would like the create_blog
function to also register 2 aditional rules (if those are not previously defined) and 1 aditional file /feeds/news.xml
:
compile /feeds\/.+/ do
filter :erb
end
route /feeds\/.+/ do
item.identifier.chop + '.xml'
end
I can generate the file all right, but in order to keep the site modularized I want to create those above rules in the create_blog
itself. This allows me to later, if I want to remove the blog, just comment out the module and not change Rules
file.