Sha256: f55a475b585e61b85e3a12a39f1efd0b37ea50ba68b86460f6b82899802c2ebe

Contents?: true

Size: 949 Bytes

Versions: 92

Compression:

Stored size: 949 Bytes

Contents

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

      options[:block] = block if block_given?

      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

92 entries across 92 versions & 1 rubygems

Version Path
rbbt-rest-2.0.1 lib/rbbt/rest/web_tool.rb
rbbt-rest-2.0.0 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.9.1 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.9.0 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.157 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.156 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.155 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.154 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.152 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.151 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.150 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.148 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.147 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.146 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.145 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.144 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.143 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.142 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.140 lib/rbbt/rest/web_tool.rb
rbbt-rest-1.8.139 lib/rbbt/rest/web_tool.rb