jferris / effigy Goto Github PK
View Code? Open in Web Editor NEWRuby views without a templating language
Home Page: http://rdoc.info/projects/jferris/effigy
License: MIT License
Ruby views without a templating language
Home Page: http://rdoc.info/projects/jferris/effigy
License: MIT License
Effigy views create their output using the "output" method, which defaults to using Nokgiri's "to_xhtml" method. This method appends "xmlns" info to the root tag, regardless of whether the HTML document actually has an XHTML doctype. This issue can be resolved by overiding "output" and calling current_context.to_html instead.
It might be helpful for docs to be updated to reflect this use case.
I see which the most issues point to Rails. My idea is separates the project. The first will be the source base and the main goal is be free of the frameworks. So, others developers can design extensions exclusively for others fameworks, for example Sinatra.
The second will be effigy-rails, of course!
Thanks.
Perhaps best in sinatra-effigy. What's the call on framework extensions existing inside or outside of Effigy? Saw another ticket about that.
I just switched from 0.3.2 to 0.4, and since switch, several of the start tags of my HTML 5 documents are being stripped. The tags being stripped seem to include everything up to the opening <title> tag - the title text itself, the closing tag, and everything else in the doc is being returned.
Otherwise this will always error with NoMethodError:
f('h2 a').attr(:href, job.company_url)
Patch here: http://gist.github.com/276921
Same as: http://api.jquery.com/parent/
Wouldn't it make sense to assume that everything that is in your index.html.effigy is evaluated in the transform method anyways and drop a few lines of code?
At the moment, it looks like find only finds the first node that matches the selector. It would be really convenient to be able to do
Here's one
And here's another
--------
find('.hiMom') do |node|
node.text 'hi mom'
end
Hey
There might be an existing way to do this in effigy already, I'm not sure, but I've gone ahead and implemented an insert() method for adding child nodes to a parent node. For example, you can dynamically add li elements to a ul list. A list of attributes for your element can be added as well, through a Hash.
You can see an implementation I've made here:
http://github.com/robgleeson/effigy/commit/a02aeaa23b890958d6719c7db4c098f777ec3c35
It needs documented and I'm not sure if you want to add something like this but I thought I'd throw it out there. I've found it very useful in some of my own projects but there might be an existing way already .. I just couldn't find anything.
Best,
Rob
At least in Rails, Effigy expects all the HTML to be contained in one parent element. This is fine for non-Rails work where the whole document is contained in an <html> element, but in Rails, the file may be wrapped in a layout, so there's no expectation that it will contain one root element. I can work around this by making sure each Effigy template is wrapped in a <div>, but that's a little silly.
XML does not like HTML fragments. There's also Nokogiri::HTML.fragment but it caused other problems with Effigy when I tried it. Simply replacing with HTML.parse passes all tests.
Patch:
http://github.com/dancroak/effigy/commit/6a5500fdd508d591fa7a92b6ba1e9382dc68366d
A closure is evaluated in the context it was defined in when passed onto Effigy::View#render which means Effigy::View isn't in context and you can't instance methods found on that class.
I made a patch: http://github.com/robgleeson/effigy/commit/86522c281f21b969f4a5726f4385009e2947fc22 and reported it to the network effigy is in but no replies.
I'm with a little issue here. Every time I try to access an HTML tag identified with class or id in my template, Effigy returns me a 'No element matched the given selector' error.
For example, I have a simple template with <div class="page">
, and in my view I look for it with find('div.page').replace_each(@pages)...
, and I always get this error.
I don't know what I'm doing wrong. I've already tested on others computers and other examples, and the problem persists.
Any suggestions?
Right now, rendering with Effigy brings back the DOCTYPE, html, and body tags. My use case is on an Ajax call which just returns an HTML fragment that jQuery then replaces in the DOM. The extra tags around it messes up.
My current hack is:
def output
current_context.to_html.sub(/.*<body>/, '').sub(/<\/body>.*/, '')
end
Same as: http://api.jquery.com/append/
It would be really nice to be able to use Haml for template files. (Yes, I know it's an interpolation-based language, but the syntax is lots nicer than plain HTML.) The only Effigy+Haml solution I've seen is http://gist.github.com/261527, and I'm not sure how to generalize that to Rails.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.