Showing
3 changed files
with
21 additions
and
7 deletions
| ... | ... | @@ -12,7 +12,19 @@ module Kanjai |
| 12 | 12 | |
| 13 | 13 | Nokogiri::HTML::Builder.with(@doc) do |subparts| |
| 14 | 14 | @repeat_type_index = {} |
| 15 | - TemplateGenerator.method("#{type}_generator").call(session, domain, elements, subparts, @original_hash_value[0]) | |
| 15 | + if type == "subMenuTemplate" | |
| 16 | + type = "menu" | |
| 17 | + current_page = nil | |
| 18 | + if session[:current_page_id] | |
| 19 | + current_page = Kanjai::Page.find_by_id(session[:current_page_id]) | |
| 20 | + while current_page && current_page.parent && current_page.page_template == current_page.parent.page_template | |
| 21 | + current_page = current_page.parent | |
| 22 | + end | |
| 23 | + end | |
| 24 | + TemplateGenerator.method("#{type}_generator").call(session, domain, elements, subparts, @original_hash_value[0], current_page) | |
| 25 | + else | |
| 26 | + TemplateGenerator.method("#{type}_generator").call(session, domain, elements, subparts, @original_hash_value[0]) | |
| 27 | + end | |
| 16 | 28 | end |
| 17 | 29 | |
| 18 | 30 | @doc.css("img[@src]").each do |x| |
| ... | ... | @@ -32,10 +44,10 @@ module Kanjai |
| 32 | 44 | case item[:name] |
| 33 | 45 | when 'text' |
| 34 | 46 | content = item[:source] |
| 35 | - if current_page | |
| 36 | - content = content.gsub('###link###', current_page.menu_url('http://', lang = nil)) | |
| 37 | - .gsub('###title###', current_page.lang_attributes(domain.page_langs.default, :title)) | |
| 38 | - end | |
| 47 | + #if current_page | |
| 48 | + # content = content.gsub('###link###', current_page.menu_url('http://', lang = nil)) | |
| 49 | + # .gsub('###title###', current_page.lang_attributes(domain.page_langs.default, :title)) | |
| 50 | + #end | |
| 39 | 51 | subparts << content |
| 40 | 52 | when 'repeat' |
| 41 | 53 | #get template for normal state, active state and separator |
| ... | ... | @@ -273,7 +285,8 @@ module Kanjai |
| 273 | 285 | end |
| 274 | 286 | elsif item[:name] == 'p' |
| 275 | 287 | if item[:children].count > 0 |
| 276 | - subparts << "<p>#{self.replace_text_marker('p', item[:children][0][:source], hash_value).html_safe}</p>" | |
| 288 | + #subparts << "<p>#{self.replace_text_marker('p', item[:children][0][:source], hash_value).html_safe}</p>" | |
| 289 | + subparts.p(attributes, self.replace_text_marker('p', item[:children][0][:source], hash_value).html_safe) | |
| 277 | 290 | end |
| 278 | 291 | else |
| 279 | 292 | subparts.send(item[:name], attributes) do |next_subparts| | ... | ... |