Re: [Radiant] Summer doc project - Writing an radius tag extension article

2008-06-25 Thread Alex Wayne

But the provided matcher that does

  page.should render(tag).as(expected)

is so handy!  But you are definitely right.  White space issues  
especially make this a bit cumbersome.  Perhaps that matcher needs to  
be expanded.  What if you could do this:


  page.should render(tag).with_tag('h1', 'Test Title')

or even

  page.should render(tag).with_tags do |output|
output.should have_tag('div') do |div|
  div.should have_tag('p', 'Content')
end
  end

that would make speccing custom tags far easier I think.  Plus it  
should be easy to just hook into the have_tag matcher.  I smell  
another patch brewing...


-Alex
http://beautifulpixel.com

On Jun 25, 2008, at 8:24 AM, Andrew O'Brien wrote:


Nice work!

One thing I'd add to your spec section (and I'll let you decide how
you want to integrate this into the article) is to use should
have_tag instead of string comparison.  The main disadvantage I've
found with strings is that it's hard to track down individual
characters sometimes (especially if they're blanks) and can be quite
fragile when the code is changed.

I've put up a pastie with some spec code that uses should have_tag:

http://pastie.org/private/xgab7akob3tqbxdltzeeg

(The before is a little nasty -- I wrote this before scenarios where
available.)  Feel free to adapt this to the examples in the article
(or get in touch with me if you'd like some assistance).

-Andrew

On Tue, Jun 24, 2008 at 11:15 PM, Alex Wayne  
[EMAIL PROTECTED] wrote:
Radiant 0.6.7 generates extensions with a spec directory by  
default, and no

test directory at all. Its all hooked up already for ya.

-Alex

On Jun 24, 2008, at 7:50 PM, Marty Haught [EMAIL PROTECTED]  
wrote:


On Tue, Jun 24, 2008 at 3:26 PM, Alex Wayne  
[EMAIL PROTECTED]

wrote:


I got inspired this morning and managed to complete an article  
about

writing
an extension to implement a custom tag, with a spec driven process.

http://wiki.radiantcms.org/Creating_an_extension_I

I hope its accurate, as I am still a bit of a noob with Radiant.


Nice start to the article.  I'm curious on your steps on integrating
rspec and scenarios into your extension.  I just started the  
migration
to spec and scenarios from test:unit and fixtures and am getting  
some

strange errors.  We should definitely document any additional steps
beyond running the extension generator for getting up and running.

Cheers,
Marty
___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Summer doc project - Writing an radius tag extension article

2008-06-25 Thread Marty Haught
I think it all matters based on your context.  I do agree that I would
follow Sean's approach first.  For example, Alex, I might do this:

r:box
div class=box
 h2
   img src=/images/icons/r:icon /.png /
   r:title /
 /h2
 div class=content
   r:content /
 /div
/div
/r:box

You can scope your radius tags so you don't have to repeat the box
part.  I'm not 100% on how name collisions happen but I'm sure Sean or
someone else can speak up to that.

Here's an example of a tag from my page event extension that I would
not break down, r:events:calendar /.  It outputs a table tag filled
with all the rows for the current month's calendar.  As the tag
designer I decided to keep the calendar html structure hard-coded.  I
expect that if people want to change how it looks they'll use css.

So in the end you'll have to determine if your tag's use should allow
more customization or be hard-coded inside the tag.  There can be more
work breaking down each tag than doing a single whole tag. However, if
you ever have to change it (like via attributes or some such) you have
been wishing that you hadn't gone with a single tag.

Cheers,
Marty



On Wed, Jun 25, 2008 at 11:29 AM, Alex Wayne [EMAIL PROTECTED] wrote:
 Learn new things everyday.  Do you have a brief example of that?  One of the
 reasons I have written some custom tags such as this is because there is no
 way to pass arguments to snippets.

 So if I understood you right, I can have a snippet:

 div class=box
  h2
img src=/images/icons/r:box:icon /.png /
r:box:title /
  /h2
  div class=content
r:box:content /
  /div
 /div

 Then I define my r:box tag to render that snippet, capturing icon and
 title from the attributes of the tag, and use that in the expansion of
 r:box:title and r:box:icon?

 That does seem quite a bit cleaner.  Perhaps not having render(tag).with_tag
 matcher is some syntatic vinegar to discourage what I did in the first
 place.  Also, this approach may not be the best case for writing your first
 extension then.  It involves a bit more steps and probably is better as a
 later lesson.


 -Alex
 http://beautifulpixel.com
___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Summer doc project - Writing an radius tag extension article

2008-06-24 Thread Alex Wayne
Radiant 0.6.7 generates extensions with a spec directory by default,  
and no test directory at all. Its all hooked up already for ya.


-Alex

On Jun 24, 2008, at 7:50 PM, Marty Haught [EMAIL PROTECTED] wrote:

On Tue, Jun 24, 2008 at 3:26 PM, Alex Wayne  
[EMAIL PROTECTED] wrote:
I got inspired this morning and managed to complete an article  
about writing

an extension to implement a custom tag, with a spec driven process.

http://wiki.radiantcms.org/Creating_an_extension_I

I hope its accurate, as I am still a bit of a noob with Radiant.


Nice start to the article.  I'm curious on your steps on integrating
rspec and scenarios into your extension.  I just started the migration
to spec and scenarios from test:unit and fixtures and am getting some
strange errors.  We should definitely document any additional steps
beyond running the extension generator for getting up and running.

Cheers,
Marty
___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

___
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant