You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use Sablon for docx templating, and we perform MailMerge operations on our server. We quite often run into this stacktrace here:
undefined method `parent' for nil
/vendor/ruby/3.3.0/gems/sablon-0.4.1/lib/sablon/content.rb:136:in `add_siblings_to'
/vendor/ruby/3.3.0/gems/sablon-0.4.1/lib/sablon/content.rb:88:in `append_to'
/vendor/ruby/3.3.0/gems/sablon-0.4.1/lib/sablon/parser/mail_merge.rb:35:in `replace_field_display'
/vendor/ruby/3.3.0/gems/sablon-0.4.1/lib/sablon/parser/mail_merge.rb:56:in `replace'
/vendor/ruby/3.3.0/gems/sablon-0.4.1/lib/sablon/operations.rb:7:in `evaluate'
/vendor/ruby/3.3.0/gems/sablon-0.4.1/lib/sablon/processor/document.rb:75:in `block in manipulate'
/vendor/ruby/3.3.0/gems/sablon-0.4.1/lib/sablon/processor/document.rb:74:in `each'
/vendor/ruby/3.3.0/gems/sablon-0.4.1/lib/sablon/processor/document.rb:74:in `manipulate'
/vendor/ruby/3.3.0/gems/sablon-0.4.1/lib/sablon/processor/document.rb:61:in `process'
/vendor/ruby/3.3.0/gems/sablon-0.4.1/lib/sablon/template.rb:75:in `block (2 levels) in process'
... and 109 more lines
I can't seem to find a way to consistently reproduce this, but looking at the code, it seems like Sablon is appending to a paragraph, and then removing that paragraph — could that be causing the issue?
# /vendor/ruby/3.3.0/gems/sablon-0.4.1/lib/sablon/content.rb:88:in `append_to'defappend_to(paragraph,display_node,env)# if all nodes are inline then add them to the existing paragraph# otherwise replace the paragraph with the new content.ifall_inline?pr_tag=display_node.parent.at_xpath('./w:rPr')add_siblings_to(display_node.parent,pr_tag)display_node.parent.removeelseadd_siblings_to(paragraph)# <--- This is where it crashesparagraph.removeendend
Update: I believe this happens if you place multiple variables on the same line, especially if these variables insert more complex things like tables. Seems like if one of the variables isn't inline, the paragraph is replaced with the variables content, but the next variable then has no parent
The text was updated successfully, but these errors were encountered:
We use Sablon for docx templating, and we perform MailMerge operations on our server. We quite often run into this stacktrace here:
I can't seem to find a way to consistently reproduce this, but looking at the code, it seems like Sablon is appending to a paragraph, and then removing that paragraph — could that be causing the issue?
Update: I believe this happens if you place multiple variables on the same line, especially if these variables insert more complex things like tables. Seems like if one of the variables isn't inline, the paragraph is replaced with the variables content, but the next variable then has no parent
The text was updated successfully, but these errors were encountered: