lib/wikicloth/parser.rb in wikicloth-0.2.0 vs lib/wikicloth/parser.rb in wikicloth-0.5.0

- old
+ new

@@ -44,10 +44,16 @@ options ||= [] self.instance_exec(resource,options,&block) end end + def template(&block) + self.send :define_method, 'template' do |template| + self.instance_exec(template,&block) + end + end + def link_for_resource(&block) self.send :define_method, 'link_for_resource' do |prefix,resource,options| options ||= [] self.instance_exec(prefix,resource,options,&block) end @@ -57,16 +63,10 @@ self.send :define_method, 'section_link' do |section| self.instance_exec(section,&block) end end - def template(&block) - self.send :define_method, 'template' do |template| - self.instance_exec(template,&block) - end - end - def link_for(&block) self.send :define_method, 'link_for' do |page,text| self.instance_exec(page,text,&block) end end @@ -78,10 +78,10 @@ end end # Replace a section, along with any sub-section in the document def put_section(id,data) - data = @wikicloth.sections.first.wikitext({ :replace => { id => data } }) + data = @wikicloth.sections.first.wikitext({ :replace => { id => data.last(1) == "\n" ? data : "#{data}\n" } }) @wikicloth = WikiCloth.new(:data => data, :link_handler => self, :params => @params) end # Get the section, along with any sub-section of the document def get_section(id)