# Dynamic Attributes in a Snippet Tag?

**URL:** <https://www.ruby-forum.com/t/dynamic-attributes-in-a-snippet-tag/73793>\
**Category:** Radiant CMS\
**Created:** [October 27, 2006, 2:56am UTC](https://www.ruby-forum.com/t/dynamic-attributes-in-a-snippet-tag/73793 "2006-10-27T02:56:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lorenjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b5a626/32.png) [@lorenjohnson](https://www.ruby-forum.com/u/lorenjohnson)\
**Post date:** [October 27, 2006, 2:56am UTC](https://www.ruby-forum.com/t/dynamic-attributes-in-a-snippet-tag/73793/1 "2006-10-27T02:56:03Z")

</div>

Has anyone ever thought about adding an attribute to a Snippet call

e.g. \<r:snippet linktext=“Read more of this column” /\>

and then having a way of pulling that attribute in the Snippet all using  
Radius tags?:

e.g. Snippet content \<r:linktext /\> more Snippet content…

This is one of those things which could lead to all “misuse” of Radiant  
I suppose, but it would sure be an easy implemenation that would enable  
a number of useful and potentially in-scope applications.

I have a particular use-case if there is any interest.

Thanks,

Loren J.  
AIM: NL7XF  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![lorenjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b5a626/32.png) [@lorenjohnson](https://www.ruby-forum.com/u/lorenjohnson)\
**Post date:** [October 27, 2006, 3:33pm UTC](https://www.ruby-forum.com/t/dynamic-attributes-in-a-snippet-tag/73793/2 "2006-10-27T15:33:38Z")

</div>

You could do something similar, but it wouldn’t work that way because  
you  
would have to define the tag when you were already parsing! Instead you  
would have to make modifications to the “snippet” tag definition to  
record  
attributes it doesn’t use in a tag.locals, and then add a new tag, say  
“echo” that outputs individual dynamic attributes. \<r:echo  
attr=“linktext”  
/\>, for example. Still, I don’t see what that accomplishes.

Sean C.  
[seancribbs.com](http://seancribbs.com)

---

<div class="post-metadata">

**Author:** ![lorenjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b5a626/32.png) [@lorenjohnson](https://www.ruby-forum.com/u/lorenjohnson)\
**Post date:** [October 27, 2006, 4:43pm UTC](https://www.ruby-forum.com/t/dynamic-attributes-in-a-snippet-tag/73793/3 "2006-10-27T16:43:45Z")

</div>

On 10/27/06, Sean C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Still, I don’t see what that accomplishes.

Giving snippets context?

---

<div class="post-metadata">

**Author:** ![lorenjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b5a626/32.png) [@lorenjohnson](https://www.ruby-forum.com/u/lorenjohnson)\
**Post date:** [October 28, 2006, 2:24am UTC](https://www.ruby-forum.com/t/dynamic-attributes-in-a-snippet-tag/73793/4 "2006-10-28T02:24:48Z")

</div>

Loren,

It sounds like you need page parts, but if I’m understanding you  
correctly, you need at least one snippet so it can be evaluated in the  
template or in multiple pages. A page part would contain the summary,  
which would be accessed and formatted by the snippet.

Sean

---

<div class="post-metadata">

**Author:** ![lorenjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b5a626/32.png) [@lorenjohnson](https://www.ruby-forum.com/u/lorenjohnson)\
**Post date:** [October 28, 2006, 3:44am UTC](https://www.ruby-forum.com/t/dynamic-attributes-in-a-snippet-tag/73793/5 "2006-10-28T03:44:53Z")

</div>

We do currently use a Summary page part and a ArticleSummary snippet.  
In the following scenario it allows us to flow-in article summaries  
with 3 lines of markup instead of 6. Big deal… but it would allow  
us to build-up a CMS vocabulary and more viably bring a client  
directly into the content management themselves. I do understand that  
this sort of simplified Content Management workflow stuff begins to  
fall out of the scope of Radiant as so far articulated.

I digress.

Loren

On Oct 27, 2006, at 6:26 PM, Sean C. wrote:

> > So I say to Paul, no problem I’ll just through that little set of  
> > spots if we want to change something global outside the scope of  
> > \<r:find url=“/news/ecs/article/” \>
> 
> Post: removed\_email\_address@domain.invalid  
> Search: [http://radiantcms.org/mailing-list/search/](http://radiantcms.org/mailing-list/search/)  
> Site: [http://lists.radiantcms.org/mailman/listinfo/radiant](http://lists.radiantcms.org/mailman/listinfo/radiant)

Loren J.  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![lorenjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b5a626/32.png) [@lorenjohnson](https://www.ruby-forum.com/u/lorenjohnson)\
**Post date:** [October 27, 2006, 11:42pm UTC](https://www.ruby-forum.com/t/dynamic-attributes-in-a-snippet-tag/73793/6 "2006-10-27T23:42:40Z")

</div>

Sean and Mislav thanks for the responses –

For what it’s worth, below is the use case for dynamic attributes in  
Snippets. There are things that I’d like to see added to a Radiant  
release more and before than this without question (page reordering  
and reparenting please), but at least here is a use case for the  
record of what I think could be an easy, useful and possibly in-scope  
extension to Snippets.

An Article Summary Template

I work with a designer for most everything I do. His HTML/CSS skills  
are poor. We are just finishing-up a site (http://  
[diopa.grimedesign.com](http://diopa.grimedesign.com)) and in that site on several pages we pull-in  
the summary part of an article and attached a nice little header  
which spits out the name of the Section and the date the Article was  
posted before the title. This summary pattern repeats many times and  
is always the same except that we like to customized the link text  
which goes to the full article. Everything else is dynamic.

So I say to Paul, no problem I’ll just through that little set of  
tags into a snippet such that he can do a

\<r:find url=“/news/ecs/article”\>  
\<r:snippet name=“summary” linkText=“Read more about this on ECS  
News” /\>  
\</r:find\>

This means that he doesn’t have to copy and paste a format for this  
summary over and over as he populates the site with content. It also  
of course means we don’t have to change it in all those spots if we  
want to change something global outside the scope of the CSS in this  
summary format.

We had considered using another page part called "linkText’ to  
accomplish the same end, however we have situations where the same  
article is posted in multiple places on the site in different  
contexts and the link text changes accordingly.

Without any of these options working we’re left with the acceptable,  
though less than preferable solution of:

\<r:find url=“/news/ecs/article/” \>

 Read more about this on ECS News...

Cheers,

Loren J.  
removed\_email\_address@domain.invalid
