lib/malt/engines/bluecloth.rb in malt-0.3.0 vs lib/malt/engines/bluecloth.rb in malt-0.4.0
- old
+ new
@@ -6,30 +6,40 @@
class BlueCloth < Abstract
register :markdown, :md
# Convert Markdown text to HTML text.
- def render(params)
- text = params[:text]
+ def render(params={})
into = params[:to]
+
+ text = parameters(params, :text)
+
case into
when :html, nil
- intermediate(params).to_html
+ prepare_engine(params).to_html
else
super(params)
end
end
- # Convert Markdown text to intermediate object.
- def intermediate(params)
- text = params[:text]
- ::BlueCloth.new(text)
+ # Prepare engine for rendering.
+ #def prepare_engine(params={})
+ # create_engine(params)
+ #end
+
+ # Instantiate engine class and cache if applicable.
+ def create_engine(params={})
+ text = parameters(params, :text)
+
+ cached(text) do
+ ::BlueCloth.new(text)
+ end
end
- private
+ private
# Load bluecloth library if not already loaded.
- def initialize_engine
+ def require_engine
return if defined? ::BlueCloth
require_library 'bluecloth'
end
end