Sha256: eb632fd4e8f74c21d6f0e012319f026cf8d87c9796c9253b5c26107ba6e51b71

Contents?: true

Size: 600 Bytes

Versions: 6

Compression:

Stored size: 600 Bytes

Contents

# frozen_string_literal: true

# inspired by https://github.com/haml/haml/blob/main/lib/haml/plugin.rb
module Serbea

  # This module makes Serbea work with Rails using the template handler API.
  class Plugin
    def handles_encoding?; true; end

    def compile(template, source)
      "self.class.include(Serbea::Helpers);" + Tilt::SerbeaTemplate.new { source }.precompiled_template([])
    end

    def self.call(template, source = nil)
      source ||= template.source

      new.compile(template, source)
    end
  end
end

ActionView::Template.register_template_handler(:serb, Serbea::Plugin)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
serbea-0.7.0 lib/serbea/rails_support.rb
serbea-0.6.4 lib/serbea/rails_support.rb
serbea-0.6.3 lib/serbea/rails_support.rb
serbea-0.6.2 lib/serbea/rails_support.rb
serbea-0.6.1 lib/serbea/rails_support.rb
serbea-0.6.0 lib/serbea/rails_support.rb