KKBOX / FireApp

Fire.app is a HTML prototyping tool with Sass/Compass/ERB/Haml/Slim/Markdown support
http://fireapp.kkbox.com/
GNU General Public License v2.0
613 stars 79 forks source link

HAML global variables not supported? #176

Open alexandrethsilva opened 11 years ago

alexandrethsilva commented 11 years ago

When trying to use global variables to exchange definitions through the _layout.html.haml and rendered partials an error is generated.

_layout.html.haml

- $cdn_url = "//cdnurl.com"

_index.html.haml

= render :partial => "components/toolbar"

components/_toolbar.html.haml

%img{:src => "#{$cdn_url}/skin/images/logo.png"}

Throws the following error:

NameError at /public/mobile/
undefined local variable or method `cdn_url' for #<Serve::DynamicHandler::Context
Ruby    (__TEMPLATE__): in __singleton__, line 9

Traceback (innermost first)

(__TEMPLATE__): in __singleton__
org/jruby/RubyKernel.java: in instance_eval
org/jruby/RubyMethod.java: in call
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tilt-1.4.1/lib/tilt/template.rb: in evaluate
      method.bind(scope).call(locals, &block)...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tilt-1.4.1/lib/tilt/haml.rb: in evaluate
        super...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tilt-1.4.1/lib/tilt/template.rb: in render
      evaluate scope, locals || {}, &block...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tka-serve/lib/serve/handlers/dynamic_handler.rb: in parse_file
        @engine.render(context, locals) do |*args|...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tka-serve/lib/serve/view_helpers.rb: in render_template
        parser.parse_file(filename, options[:locals])...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tka-serve/lib/serve/view_helpers.rb: in render_partial
      render_template(partial, options.merge(:partial => true))...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tka-serve/lib/serve/view_helpers.rb: in render
        render_partial(partial, options)...
(__TEMPLATE__): in capture_haml
org/jruby/RubyProc.java: in call
org/jruby/RubyProc.java: in call
/Applications/Fire.app/Contents/Resources/lib/ruby/common/haml-4.0.3/lib/haml/helpers.rb: in capture_haml
        block.call(*args)...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/haml-4.0.3/lib/haml/helpers.rb: in with_haml_buffer
      yield...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/haml-4.0.3/lib/haml/helpers.rb: in capture_haml
      with_haml_buffer(buffer) do...
org/jruby/RubyKernel.java: in send
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tka-serve/lib/serve/view_helpers.rb: in capture
        send capture_method, &block...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tka-serve/lib/serve/view_helpers.rb: in content_for
      content = capture(&block) if block_given?...
(__TEMPLATE__): in __singleton__
org/jruby/RubyKernel.java: in instance_eval
org/jruby/RubyMethod.java: in call
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tilt-1.4.1/lib/tilt/template.rb: in evaluate
      method.bind(scope).call(locals, &block)...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tilt-1.4.1/lib/tilt/haml.rb: in evaluate
        super...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tilt-1.4.1/lib/tilt/template.rb: in render
      evaluate scope, locals || {}, &block...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tka-serve/lib/serve/handlers/dynamic_handler.rb: in parse_file
        @engine.render(context, locals) do |*args|...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tka-serve/lib/serve/handlers/dynamic_handler.rb: in parse
        parser.parse_file(@script_filename)...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tka-serve/lib/serve/handlers/dynamic_handler.rb: in process
      response.body = parse(request, response)...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tka-serve/lib/serve/rack.rb: in process
            handler.new(@root, path).process(request, response)...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/tka-serve/lib/serve/rack.rb: in call
      process(request, response).to_a...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/rack-1.4.1/lib/rack/cascade.rb: in call
        result = app.call(env)...
org/jruby/RubyArray.java: in each
/Applications/Fire.app/Contents/Resources/lib/ruby/common/rack-1.4.1/lib/rack/cascade.rb: in call
      @apps.each do |app|...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/rack-1.4.1/lib/rack/showexceptions.rb: in call
      @app.call(env)...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/rack-1.4.1/lib/rack/showstatus.rb: in call
      status, headers, body = @app.call(env)...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/rack-1.4.1/lib/rack/commonlogger.rb: in call
      status, header, body = @app.call(env)...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/rack-1.4.1/lib/rack/builder.rb: in call
      to_app.call(env)...
/Applications/Fire.app/Contents/Resources/lib/ruby/common/rack-1.4.1/lib/rack/handler/webrick.rb: in service
        status, headers, body = @app.call(env)...
file:/Applications/Fire.app/Contents/Resources/Java/lib/java/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/1.8/webrick/httpserver.rb: in service
      si.service(req, res)...
file:/Applications/Fire.app/Contents/Resources/Java/lib/java/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/1.8/webrick/httpserver.rb: in run
          server.service(req, res)...
file:/Applications/Fire.app/Contents/Resources/Java/lib/java/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/1.8/webrick/server.rb: in start_thread
          block ? block.call(sock) : run(sock)...
org/jruby/RubyProc.java: in call
org/jruby/RubyProc.java: in call

@handlino: any idea on how to make this work? it works on other projects not running through FireApp and it's part of the HAML 4.01 specification...

tka commented 11 years ago

@alexandrethsilva "it works on other projects not running through FireApp" can you show me the details?

alexandrethsilva commented 10 years ago

@tka Hey man, sorry. Didn't see this comment before. What kind of details are you referring to? The example I've put when served by e.g. a simple POW server runs OK, but not on FireApp, which I was using to automatically compile my SASS files and so on...