Skip to content

Instantly share code, notes, and snippets.

@edbond
Created December 3, 2008 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edbond/31498 to your computer and use it in GitHub Desktop.
Save edbond/31498 to your computer and use it in GitHub Desktop.
# AV/base.rb
def render(options = {}, local_assigns = {}, &block) #:nodoc:
local_assigns ||= {}
"<!--DBG #{options[:layout]} #{options[:file]} #{options[:partial]} #{options[:text]}-->"+
if options.is_a?(String)
ActiveSupport::Deprecation.warn(
"Calling render with a string will render a partial from Rails 2.3. " +
"Change this call to render(:file => '#{options}', :locals => locals_hash)."
)
render(:file => options, :locals => local_assigns)
elsif options == :update
update_page(&block)
elsif options.is_a?(Hash)
options = options.reverse_merge(:locals => {})
if options[:layout]
_render_with_layout(options, local_assigns, &block)
elsif options[:file]
_pick_template(options[:file]).render_template(self, options[:locals])
elsif options[:partial]
render_partial(options)
elsif options[:inline]
InlineTemplate.new(options[:inline], options[:type]).render(self, options[:locals])
elsif options[:text]
options[:text]
end
end+
"<!--ENDDBG #{options[:file]} #{options[:partial]}-->"
end
// js
Event.addBehavior({
'*:mousemove':function(evt) {
var el=this;
var s=null;
do {
el=el.parentNode;
if (!el)
break;
// look for comments
s=el.previousSibling;
while (s) {
if (s.nodeType==Node.COMMENT_NODE) {
console.log(s.textContent);
};
s=s.previousSibling;
}
} while (el != null);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment