Sha256: 3839b15d92fc510342810585c0e3597963145463210ad78b44a527a7fd842c75

Contents?: true

Size: 850 Bytes

Versions: 8

Compression:

Stored size: 850 Bytes

Contents

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

      template_file = locate_template("tools/#{toolname}")
      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

8 entries across 8 versions & 1 rubygems

Version Path
rbbt-rest-1.6.5 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.4 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.3 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.2 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.1 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.6.0 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.5.0 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.4.13 lib/rbbt/rest/web_tool.rb