olivernn / poirot Goto Github PK
View Code? Open in Web Editor NEWmustaches in your rails
Home Page: http://olivernn.github.com/poirot
mustaches in your rails
Home Page: http://olivernn.github.com/poirot
It'd be nice if I could use the {{> partial}}
syntax to render partials. Right now it doesn't find the partial; perhaps it's not going through the Rails asset pipeline at all?
I am rendering a haml partial inside a Poirot::View subclass, something like this
class IndexView
def add_something
render :partial => "path/to/haml/partial"
end
end
the rails process crashes with SEG FAULT in the "render :partial" line
Is it possible to have the last version of mustache.js? As it is stated here:
"NOTICE: The dot notation feature was recently implemented for the 0.4 release, which is not out as of Nov 9 2011. You can find the feature in the current master branch of mustachejs".
This new version brings the dot notation feature!
Trying to use Rails' render
method inside a Poirot::View
when trying to render a rails partial call's Mustache's render
(which is fine, but should be called out clearly in documentation).
The solution is to use controller.render_to_body
if you want to render a partial into a mustache template. Again, just a doc update.
I'm trying to use Cells [https://github.com/apotonick/cells] to create reusable view components. The view that I want to make reusable already exists, and it uses Poirot templates. The problem is template_include_tag
which requires that all templates live inside of app\views
whereas Cell keeps its view templates in app\cells
.
A secondary problem is that, while cells are like controllers, they don't implement the controller_name
method. This could be hacked around using an absolute path if Poirot had some way to either specify a rooted path (kinda yuck) or to search for templates in the current folder. Regarding this last suggestion I'm not sure if there is a way to know from a helper what file it's running from. If not, maybe there could be some way to denote that the file references is rooted at app
instead of app/views
. Perhaps like ~/path/to/mustache/template
Hey, is there a way to get this to work for ActionMailer as well? Currently when I try to use a foo.text.mustache template, I get an exception in my Mailer class:
ActionView::Template::Error: undefined method `params' for #<MyMailer:0x007fa738e84c20>
path/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.11/lib/action_view/helpers/controller_helper.rb:10:in `params'
from path/.rvm/gems/ruby-1.9.3-p194/gems/poirot-0.2.4/lib/poirot/view.rb:8:in `initialize'
Hopefully my last issue. Any help would be greatly appreciated.
I'm trying to access my helper methods in my optional view class. For example:
# View Class
module Users
class UserListView < Poirot::View
def foo
"bar"
end
end
end
// JS call (coffeescript)
users = poirot.userList()
When loading the template with data, anything I define inside the JS obviously makes it into the view except for {{ foo }}.
How can I add a view class method for something like {{ user.username }}?
It would be wonderful if stache could handle template files like _posts.html.haml.mustache
or _posts.html.erb.mustache
.
Is is possibile? I can help if you provide me with the right directions!
Thank you for this wonderful gem!
Hello,
I'm working on a copy of poirot that I have adapted for my needs, in the context of a 3.1 mountable engine, so I'm not sure if the problem exists on your version, but just in case you hit it :
I had to change the method_missing method in Poirot::View : https://github.com/olivernn/poirot/blob/master/lib/poirot/view.rb#L18
When I was calling "new_whatever_path" in a subclass, it returned me nil. Problem is, instance_var was tested to see if it was defined, which I don't understand how it can not be, since it's defined in the previous line.
So, I changed the method to :
def method_missing(method_name, *args, &block)
if instance_variable_defined?( "@#{method_name}" ) && args.empty?
instance_variable_get("@#{method_name}")
else
view_context.send(method_name,*args, &block)
end
end
I'm finally upgrading an app to Rails 4 which relies heavily on Poirot. Upon server side render of a partial I'm getting:
undefined method `_partial_renderer' for #<ActionView::Renderer:0x007fde81364b08>
I assume this is because Rails 4 is not supported. Correct? What are my options?
It appears that the handler ignores local variables passed to a partial.
I see <script id="post-list-template" filled but no poirot.js is loaded.
I tried adding poirot to application.js but it didn't fixed it
When I run cucumber/selenium the execution gets stuck when template_include_tag is called. After playing around with it, I realized that the parameterize
call causes this error.
I came up with a patch for the whole method (because also the template file wouldn't get closed):
module Poirot
module AssetHelper
def template_include_tag(*sources)
sources.collect do |source|
template = File.read(resolve_partial_path(source))
template_name = source.to_s.split('/').last.dasherize
content_tag :script, template.html_safe, :type => "text/mustache", :id => "#{template_name}-template"
end.join("\n").html_safe
end
end
end
This works perfectly for me and even the template_name method is obsolete. Is there a case where parameterize is really necessary?
Thanks for the great gem. The only thing I'm having trouble with is accessing my templates client-side using poirot.viewName(), as it seems poirot isn't being defined in my js.
I'm using Rails 3.1, and the rails g poirot:installer isn't available. Any ideas as to what the issue might be?
Thanks again
I am getting this error with rails 3.0.10:
undefined method `view_renderer' for #<#<Class:0x0000000b9d2fc8>:0x0000000b9ccc90>
in
vendor/gems/poirot/lib/poirot/view.rb:41:in `assign_variables!'
I like this gem but Handlebars seems more flexible, it would be much different to switch or port to a similar template language?
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.