How to reference a tag made available by an extension in my own custom tag extension

11 views
Skip to first unread message

Errol Siegel

unread,
Jan 29, 2014, 1:21:23 PM1/29/14
to radia...@googlegroups.com
I have written my own simple tag extension as a helper for displaying blocks of repeating html.

For example, let's say I have this pattern:

<ul>
<li>first chunk of text<br /><div class="some_class">second chunk of text</div><br /><b>third chunk of text</b></li>
<li>first chunk of text<br /><div class="some_class">second chunk of text</div><br /><b>third chunk of text</b></li>
<li>first chunk of text<br /><div class="some_class">second chunk of text</div><br /><b>third chunk of text</b></li>
<li>first chunk of text<br /><div class="some_class">second chunk of text</div><br /><b>third chunk of text</b></li>
</ul>

I realize the above markup doesn't make much sense, but it's just there to illustrate the issue.

Anyhow, for convenience I made my own extension that allows me to do this instead:

<ul>
<r:my_tag attribute1="text1" attribute2="text2">a bunch of text</r:my_tag>
<r:my_tag attribute1="text1" attribute2="text2">a bunch of text</r:my_tag>
<r:my_tag attribute1="text1" attribute2="text2">a bunch of text</r:my_tag>
<r:my_tag attribute1="text1" attribute2="text2">a bunch of text</r:my_tag>
</ul>

This all works fine. However, I am running into the case where my markup includes an image. I am using the asset manager extension to display images like this:

<r:asset:image name="my_image"/>

The problems is this:

Is there a way for my tag extension to use the <r:asset> tag?

Jim Gay

unread,
Jan 29, 2014, 1:52:25 PM1/29/14
to radia...@googlegroups.com
I don't recall what happens if you have <r:something.../> in side a
tag attribute; whether or not it's an error or the parser just skips
it.

But I think the way we build tags should be rethought.
They currently are just blocks of procedures, but I played with some
ideas about how to make them more testable and extendable here
https://gist.github.com/saturnflyer/3500369

Using some ideas there, and assuming the parser doesn't error on you,
you might be able to set an attribute with <r:...> in it and expand
that yourself inside of a tag object.
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Radiant CMS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to radiantcms+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Write intention revealing code #=> http://www.clean-ruby.com

Jim Gay
Saturn Flyer LLC
571-403-0338

Errol Siegel

unread,
Jan 29, 2014, 3:27:31 PM1/29/14
to radia...@googlegroups.com
Thanks for the reply, Jim.

Currently, the parser just skips it (you end up with the <r:whatever /> tag output to the browser).

I'll take a look at the link you referenced.

Benny Degezelle

unread,
Jan 30, 2014, 8:52:38 AM1/30/14
to radia...@googlegroups.com
Inside your tag definition, you could use

  tag.render('r:asset:image', tag.attr)

.. assuming you would pass the 'name' attribute to <r:my_tag>.
You could also create a hash yourself to stand in for tag.attr;

  tag.render('r:asset:image', {'name' => 'my_image'})

Could you give some more info on what you're trying to do?
I have a feeling you're overlooking a simpler solution.

Op woensdag 29 januari 2014 21:27:31 UTC+1 schreef Errol Siegel:
Reply all
Reply to author
Forward
0 new messages