Sha256: f9e49a5c4443b90582576ebf5e343eef35eac7644520957e43828885cd3433b2

Contents?: true

Size: 916 Bytes

Versions: 96

Compression:

Stored size: 916 Bytes

Contents

module Sinatra
  module RbbtToolHelper
    def tool(toolname, options = {})
      options[:id] ||= toolname.to_s + "_#{rand(10000)}"

      template_file = locate_template("tools/#{toolname}")
      Log.debug "Loading tool #{toolname} from: #{template_file}"
      content = Tilt::HamlTemplate.new(template_file, :filename => template_file, :ugly => production?).render(self, options)

      styles = begin
                 path = locate_sass("tools/#{toolname}")
                 link_css "/stylesheets/tools/#{toolname}" if path.exists?
               rescue Exception
                 ""
               end

      javascript = begin
                     path = locate_javascript("tools/#{toolname}")
                     link_js "/js-find/tools/#{toolname}" if path.exists?
                   rescue Exception
                     ""
                   end

      styles + content + javascript
    end
  end
end

Version data entries

96 entries across 96 versions & 1 rubygems

Version Path
rbbt-rest-1.6.21 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.20 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.19 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.18 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.17 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.16 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.15 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.14 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.13 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.12 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.11 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.10 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.9 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.8 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.7 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.6 lib/rbbt/rest/web_tool.rb