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.8.34 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.32 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.31 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.30 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.29 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.28 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.27 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.26 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.25 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.23 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.22 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.21 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.20 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.19 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.18 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.17 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.16 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.15 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.14 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.13 lib/rbbt/rest/web_tool.rb