lib/servel/haml_context.rb in servel-0.11.0 vs lib/servel/haml_context.rb in servel-0.12.0

- old
+ new

@@ -1,9 +1,9 @@ class Servel::HamlContext + extend Servel::Instrumentation include ActiveSupport::NumberHelper - ENGINE_OPTIONS = { remove_whitespace: true, escape_html: true, ugly: true } LOCK = Mutex.new def self.render(template, locals) [200, {}, [new.render(template, locals)]] end @@ -22,15 +22,33 @@ def include(path) (@build_path + path).read end + def sort_attrs(sort, current_method) + data = { sort_method: current_method, sort_direction: "asc" } + classes = ["sortable"] + if sort[:method] == current_method + data[:sort_active] = true + data[:sort_direction] = sort[:direction] + classes << "sort-active" + classes << "sort-#{sort[:direction]}" + end + + { + data: data, + class: classes + } + end + def haml_engine(path) LOCK.synchronize do @@haml_engine_cache ||= {} unless @@haml_engine_cache.key?(path) - @@haml_engine_cache[path] = Haml::Engine.new(include(path), ENGINE_OPTIONS.merge(filename: path)) + @@haml_engine_cache[path] = Hamlit::Template.new(filename: path) { include(path) } end @@haml_engine_cache[path] end end + + instrument :render, :partial, :include end \ No newline at end of file