Comments (8)
Using add_renderer
will also make render_to_string widget: Widget
work correctly too.
from fortitude.
OK, I'm looking at this right now. Some of this stuff is just me not knowing about view_context
or add_renderer
, which I will now use. It's also test cases that I was missing. I imagine it will all be relatively quick to fix…stand by.
from fortitude.
As a side note, I don't think the add_renderer
approach adds the layout when passing layout: true
. It never worked in Erector, so I'm not too concerned, but it would probably be nice to have.
from fortitude.
view_context
is equal to the template_handler
argument that you receive in Fortitude::Rails::Renderer.render
btw
from fortitude.
add_renderer
does not work well if two renderers of the same name are added. It appears to keep the first one only. I ended up patching Erector::Rails.render
in my initializer so I could still render widgets even if Erector is loaded first: (this also handles passing a class as the widget options)
If you're planning on keeping erector/fortitude at same time support you can use or modify this.
module Erector
module Rails
class << self
def render_with_fortitude(widget, view, local_assigns = {}, is_partial = false, options = {})
if widget.is_a?(Class) && widget < ::Fortitude::Widget
widget = widget.new widget.extract_needed_assigns_from(view.assigns)
end
if widget.is_a? ::Fortitude::Widget
context = ::Fortitude::RenderingContext.new helpers_object: view
widget.render_to(context)
return context.output_buffer_holder.output_buffer.to_s
end
render_without_fortitude(widget, view, local_assigns, is_partial, options)
end
alias_method_chain :render, :fortitude
end
end
end
from fortitude.
OK, just added a whole bunch of specs to the branch ageweke/render_widget
that, I think, handle all the cases you reported above. They all fail right now, but I'm going to work on making them pass, using add_renderer
. They also cover the case of being able to use render :widget
with both Erector and Fortitude widgets simultaneously, so I'm going to do my best to make that work correctly, too.
from fortitude.
(I have to take off for a few hours shortly, so the fixes will come later this evening, just as a heads-up.)
from fortitude.
OK, master
now has fixes for all this stuff, and there are no issues that I know of remaining around this. I think I even took care of the difficult cases above — you now get layouts (unless you turn them off) using render :widget
, and I monkeypatched ActionController.add_renderer
so that even if Erector comes in to register its own handler for :widget
, we re-register after to make sure both will still work. (It seems like ActionController is last-call-wins there.)
Assuming Travis is happy, I plan to cut 0.0.9 tomorrow with all these fixes.
from fortitude.
Related Issues (20)
- Unit testing of widgets without loading entire Rails stack in test environment? HOT 2
- Script to convert to and from HTML/ERb? HOT 3
- :csrf_meta_tags helper unavailable? HOT 1
- Even more forms weirdness, or... HOT 11
- Using #inline_html with a Rails view context HOT 2
- Implicit passing of `needs` variables fails when View class is named the same as the `needs` key HOT 4
- Can't mark HTML attribute values as html_safe HOT 1
- Upgraded to Rails 4.2.5.2 and everything is blowing up HOT 3
- use controller.view_paths to resolve view paths when calculating widget_class_from_file HOT 1
- Status? HOT 8
- alias_method_chain deprecated in Rails 5 HOT 2
- fix Travis build HOT 2
- Release latest code to rubygems HOT 1
- ArgumentError: wrong number of arguments (given 5, expected 4) with ActionView 4.2.6 HOT 2
- Issues when running tests: "uninitialized constant OopRailsServer::RailsServer::Bundler" HOT 1
- Regression: automatic inclusion of Rails helpers breaks implicit route arguments HOT 6
- Fortitude prevents Rails csrf_meta_tags from being rendered in the <head> element HOT 1
- retina_images repo unavailable
- Single arity template handlers are deprecated in Rails 6.0
- Still maintained? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fortitude.