Showing
2 changed files
with
6 additions
and
6 deletions
| ... | ... | @@ -11,6 +11,7 @@ module Kanjai |
| 11 | 11 | @page_content = page_content_id.present? ? Kanjai::PageContent.find(page_content_id) : nil |
| 12 | 12 | |
| 13 | 13 | Nokogiri::HTML::Builder.with(@doc) do |subparts| |
| 14 | + @repeat_type_index = {} | |
| 14 | 15 | TemplateGenerator.method("#{type}_generator").call(session, domain, elements, subparts, @original_hash_value[0]) |
| 15 | 16 | end |
| 16 | 17 | |
| ... | ... | @@ -218,8 +219,7 @@ module Kanjai |
| 218 | 219 | when 'text' |
| 219 | 220 | subparts << self.replace_text_marker(item[:source], hash_value) |
| 220 | 221 | when 'repeat' |
| 221 | - hash_value ||= {} | |
| 222 | - repeat_item_index = hash_value['REPEAT_ITEM_INDEX'].to_i || 0 | |
| 222 | + @repeat_type_index[repeat_id] ||= 0 | |
| 223 | 223 | repeat_id = item[:attributes]['id'] |
| 224 | 224 | scope = @page_content.page_content_markers.where(repeat_id: repeat_id) |
| 225 | 225 | if hash_value && hash_value['PARENT_ITEM_ID'].present? |
| ... | ... | @@ -240,10 +240,10 @@ module Kanjai |
| 240 | 240 | value['###FIRST_ITEM_FALSE###'] = 'true' |
| 241 | 241 | end |
| 242 | 242 | value['###REPEAT_NUMBER###'] = "#{repeat_id}_#{row_index.to_s}_#{hash_value['PARENT_ITEM_ID'] || 0}" |
| 243 | - value['###REPEAT_CYCLE_COUNT###'] = repeat_item_index.to_s | |
| 243 | + value['###REPEAT_CYCLE_COUNT###'] = @repeat_type_index[repeat_id].to_s | |
| 244 | 244 | value['PARENT_ITEM_ID'] = row_index.to_s |
| 245 | - repeat_item_index += 1 | |
| 246 | - value['REPEAT_ITEM_INDEX'] = repeat_item_index.to_s | |
| 245 | + | |
| 246 | + @repeat_type_index[repeat_id] += 1 | |
| 247 | 247 | self.content_generator(session, domain, item[:children], subparts, value) |
| 248 | 248 | |
| 249 | 249 | end | ... | ... |