Forum: Radiant CMS Partials access to local objects

512e53dbf8472f0f91d485ec356ef845?d=identicon&s=25 Bradley Herman (bradherman)
on 2010-12-13 20:05
(Received via mailing list)
I'm writing an extension to add a new feature to the "taggable"
extension and I need to do something very simple: add a new column to
the taggable index page.  This is pretty simple:

admin.tag.index.add :thead, "add_required_header", :after =>
"modify_header"
admin.tag.index.add :tbody, "add_required_cell", :after =>
"modify_cell"

However, in my partial, I need to reference the tag object from
index.html.haml:

- for tag in @tags
        %tr.node.level-1
          - render_region :tbody do |tbody|
            .
            .
            .
            / Partial code should be inserted here
            / - tbody.required_cell do
            /   - if tag.required
            /     Required

However, the "tag" object is not available within the partial.  Is
there any way I can get access to that when I'm adding code via
partials?
0964828011133c856bae646e55911115?d=identicon&s=25 William Ross (spanner)
on 2010-12-13 21:23
(Received via mailing list)
On 13 Dec 2010, at 19:05, bradley.t.herman@gmail.com wrote:

> index.html.haml:
>            /     Required
>
> However, the "tag" object is not available within the partial.  Is
> there any way I can get access to that when I'm adding code via
> partials?

No. It's a weakness of the otherwise very cunning shards mechanism that
there is no way for it to get at local variables.

Taggable could help, perhaps by including an empty partial
(_other_columns.html.haml?) with some locals or by setting a
@current_tag variable within the index-page loop. Neither approach is
very pleasing, but it will take a while to arrive at a better solution
that is also simple enough to live with.

I need to clear up that index page anyway (as you can see from the
'node.level-1'). Would anyone like to suggest a best practice here?

will
This topic is locked and can not be replied to.