Skip to content

Rendering ActionText (embedded images) #331

@janpeterka

Description

@janpeterka

I seem to have problems with rendering ActionText, specifically one of the issues is embedded images not rendering.

In ERB I would do <%= report.b_1_d_explorations %> (as guide tells me).

If I do (for example) p { @report.b_1_d_explorations }, nothing gets rendered.
I can get the text rendered doing something like p { @report.b_1_d_explorations.body.html_safe }, but that doesn't render images.

I also tried to do:

  • render @report.b_1_d_explorations, which gives me Missing partial project/reports/building_permits/action_text/rich_texts/_rich_text
  • render @report.b_1_d_explorations.body, which gives me Missing partial project/reports/building_permits/action_text/contents/_content
    The second one seems closest to working solution, as only problem is that it looks for template relative from my location

I also tried

render partial("action_text/contents/content.html.erb") do
   @report.b_1_d_explorations
end

which imo SHOULD work, as it says:

Missing partial action_text/contents/_content.html.erb with {locale: [:cs], formats: [:html], variants: [], handlers: [:raw, :erb, :html, :builder, :ruby, :slim]}. Searched in: * "/home/jan/programming/dokumat/app/views" * "/home/jan/.gem/ruby/3.4.1/gems/actiontext-8.1.3/app/views" 

And action_text/contents/content.html.erb is present in gem directory:

ls /home/jan/.gem/ruby/3.4.1/gems/actiontext-8.1.3/app/views/action_text/contents/
_content.html.erb

but that might be separate issue?

I also tried register_output_helper :render_action_text_content, but then I get undefined method 'render_attachments' for an instance of ActionText::RichText

I expect this is my lack of understanding of rendering and buffer and such in Phlex (and in general), I would be glad for some pointers to understand why this doesn't work and how to write equivalent code in Phlex.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions