All,
I have some custom models which need to be represented in Radiant views, and I would like to be able to take advantage of standard Rails partials, Rails form helpers, (e.g. all the good things about ActionView).
I have a custom extension which holds all of my model information. I have, in addition, created a Radius tag that is very close to rendering a standard Rails partial using standard form helpers. I can't really see the point in using the forms extension when the field helper tags in it provide less functionality than standard Rails helpers (and there is no support for textarea <input> elements).
Generally speaking, it seems that there are 3 options:
1) Do not use Rails partials at all, enhance the existing forms extension to provide more ActionView helper-like functionality. Basically, stay within the limits of Radiant.
2) Continue down the path I'm on, which is basically wrapping a Rails partial with a Radiant tag (similar to this post from the Radiant list: http://www.ruby-forum.com/topic/133878)
3) Figure out a way to hook into the Site controller and merge content generated via both standard Rails mechanisms and Radiant (I know how to hack around double render issues, etc.). I'm thinking that the SiteController could basically become a mini-dispatcher when necessary to run standard Rails actions, and ultimately render standard Rails views/helpers, which can then be inserted into the HTTP response.
On 8/19/10 11:05 PM, Wes Gamble wrote:On 8/16/10 10:36 PM, Wes Gamble wrote:All,
I have some custom models which need to be represented in Radiant views, and I would like to be able to take advantage of standard Rails partials, Rails form helpers, (e.g. all the good things about ActionView).
Then I don't understand your use case. Either use radius tags to render your data, or use share layouts to populate your data.
> share-layouts basically allows us to plug in the holes in the Radiant layout from a Rails controller/view pair, but then all of the content must come from the Rails app., correct?
hm. radiant is the rails app.
> In my current scheme, the minimal amount of content that has to be in the Rails filesystem is there, and everything else is in Radiant, where I want it.
>
> Can you think of a way that I could successfully use share-layouts and still render a Radiant managed part in a Rails generated page?
http://github.com/screenconcept/radiant-page-part-handling-extension
>> share-layouts basically allows us to plug in the holes in the Radiant layout from a Rails controller/view pair, but then all of the content must come from the Rails app., correct?
> hm. radiant is the rails app.
I misspoke here (it was late), what I meant was to distinguish between
the two render paths available to me in the Rails app. - either
SiteController - driven [Radiant - managed rendering] or standard Rails
rendering. As far as I can tell, these two render paths are effectively
mutually exclusively across the entire page. Either my entire page is
rendered by Radius tags, or my entire page is rendered by share layouts.
Neither of these is sufficient if I need to render both content
contained inside of Radiant and content that comes from a standard Rails
request _in the same page_.
Specifically, in my applicaiton - in one page, I have a piece of content
that is rendered at the top of the page, and then a form that needs to
be rendered at the bottom. Truth be told, I could use the forms
extension to render the form, but having to hand-code all of the field
attributes was distasteful to me, when I could use a standard Rails form
builder based view, do it in Haml, and have the form view be more
readable, etc. What I probably _should_ do is change the forms
extension to be able to take advantage of the form builder stuff in
Rails, so that writing out a Radius form isn't as tedious as it is now.
Having said all of that, I'm pretty happy with what I have so far as it
gives me what I think is more flexibility.
I looked at the page-part extension as well, but it didn't seem to
address my issue, since one of my parts would be one of these forms.
I will keep thinking about it. It's certainly possible that there is a
more elegant solution.
Many thanks,
W
The Radiant user does get to control the :locals data that is passed in
to the partial, but the partial still lives outside of Radiant, so the
raw content is still outside of Radiant.
What I didn't realize is that it looks like you have access to the HTTP
response in the custom tag - is that correct? That's quite helpful.
I may try to do something like this in the future if it makes sense.
Thanks for the info.
Wes