资源说明:Unobtrusive Server Script Implementation for Ruby on Rails
= hquery (Now supports Rails3! See "Rails3" section below) Uses pure HTML as "template" for rendering views a Hpricot sequence (in the .hquery counter-part file) is executed to modify the pure HTML and the resulting HTML is output to the browser. Video: http://www.vimeo.com/1836815 == Layout If your controller is "Hello", and your action is "World", then you will need app/views/hello |-- world.hquery |-- world.hquery.html "world.hquery.html" is the vanila HTML file your designers worked on. "world.hquery" contains the ruby code to manipulate data. === Example 1 This hquery declaration: hquery.select ".users .vcard", User.find(:all) do |ele, user| ele.html ".email", user.email ele.html ".tel", user.telephone_no ele.html ".photo[@src]", user.photo end Can render this html template:=== Example 2 Google example Given an array of Hash results, the following hquery declaration uses Google's results page HTML as-is hquery.select "li.g[@style='']", @result_list do |ele, result| # each iterated html element, and its matching iterated data ele.html "a.l", result['title'] ele.html "a.l[@href]", h(result['url']) end === Example 3 Compiling conditionally removed elements This hquery declaration: hquery.remove ".nav.superuser" unless current_user && current_user.superuser? Compiled with this html template:
E-mail: foo@bar.com Contact: +1 222 333 4444
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。