Sha256: e18627bad91efe8162c9cef5539db686d348701a740787e24f1ce7c8d34b1671

Contents?: true

Size: 894 Bytes

Versions: 6

Compression:

Stored size: 894 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).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

6 entries across 6 versions & 1 rubygems

Version Path
rbbt-rest-1.8.62 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.61 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.60 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.59 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.58 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.57 lib/rbbt/rest/web_tool.rb