lazy_value icon indicating copy to clipboard operation
lazy_value copied to clipboard

Doesn't work with other template languages.

Open Greyoxide opened this issue 7 months ago • 0 comments

I'm using this library with the slim template language, and I'm consistently getting the following error Incorrect usage. Try to use "lazy_value_tag do ... end" or "lazy_value_tag { ... }" Here's how I'm using it:

= lazy_value_tag do
  = render partial: 'programs/program_card', collection: Program.all, as: :program

DIgging in a little further I can see that app/controllers/lazy_value line 3 has the following regex check REGEXP = /<%= lazy_value_tag(?:.*?)do %>(.*?)<% end %>|<%= lazy_value_tag { (.+?) } %>/m This will fail on any template language except erb.

Thinking about this further I wonder if appending this code the application_controller is the best idea. Probably this would be better handled using a railtie. Or for a more secure approach require the developer to explicitly include this library in any controller they wish to provide lazy loaded data. Something like:

class Programs::MigrationController < Programs::BaseController

  include LazyValue

  def index
    @Programs = Program.ready_for_migration
  end
  # ..... and so on

end

Greyoxide avatar Jul 09 '24 14:07 Greyoxide