Skip to content

Instantly share code, notes, and snippets.

@denisdefreyne
Created February 26, 2013 12:58
Show Gist options
  • Save denisdefreyne/5038234 to your computer and use it in GitHub Desktop.
Save denisdefreyne/5038234 to your computer and use it in GitHub Desktop.
Customisable content types for nanoc
class Text < Nanoc::Content
end
class Binary < Nanoc::Content
end
class DOM < Nanoc::Content
end
class DOMParser < Nanoc::Filter
input Nanoc::Content::Text
output Nanoc::Content::DOM
def run(content)
parse(content)
end
end
class DOMMutator < Nanoc::Filter
input Nanoc::Content::DOM
output Nanoc::Content::DOM
def run(dom)
do_stuff_with(dom)
end
end
class DOMSerializer < Nanoc::Filter
input Nanoc::Content::DOM
output Nanoc::Content::Text
def run(dom)
dom.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment