tent.io/lib/api_example.rb
2012-09-06 22:22:53 -04:00

20 lines
374 B
Ruby

require 'tent-apidoc'
class ApiExampleFilter < Nanoc::Filter
identifier :api_example
type :text
def run(content, params={})
content.gsub(/\{(\w+) example\}/) { api_example($1) }.gsub(/\{(\w+) var\}/) { api_var($1) }
end
private
def api_example(id)
TentApiDoc.examples[id.to_sym]
end
def api_var(id)
TentApiDoc.variables[id.to_sym]
end
end