repeat with an <a> tag

12 views
Skip to first unread message

Banjoey

unread,
Nov 2, 2011, 10:17:37 PM11/2/11
to Hobo Users
I am trying to create a simple menu structure. I have a model that
holds category names, and that model has_many with my other model
which is basically a page with an html type field. I want my
"category" names to be menu section headers (no links or anything),
and then under that, I want to do a repeat that will give me a link to
the "pages" of the other model. I can get the name of those pages to
display, but cannot get the link to work. Here is the dryml I have.
All my repeats seem to work, but the <a> tag just seems to have no
effect. Any suggestions?

<def tag="ministry-nav">
<navigation class="ministry-nav" merge-attrs param="default">
<% if MinistryCategory.count > 0 -%>
<% @ministry_categories = MinistryCategory.all %>
<repeat with="&@ministry_categories">
<h2 class="MinistryMenuCategories"><name/></h2>
<repeat with="&this.ministry_posts">
<a><name/></a><br/>
</repeat>
</repeat>
<% end -%>
</navigation>
</def>

Thanks,
Joey

kevinpfromnm

unread,
Nov 2, 2011, 10:54:48 PM11/2/11
to hobo...@googlegroups.com
that seems like it should work as you have it.  do you have a show page for the posts controller?

this is just minor suggestions to better use dryml's capacities for clearer/DRYer code:


<def tag="ministry-nav">
  <navigation class="ministry-nav" merge-attrs param="default">
      <repeat with="&MinistryCategory.all" if>
# the if tests for blankness of the current context if no condition is given and no need to set an instance variable if you're not using it again later

        <h2 class="MinistryMenuCategories"><name/></h2>
        <repeat:ministry_posts>
# shorthand for field="ministry_posts"

          <a /><br/>
# the default of the <a> tag is to use the model's name if no content is provided in the tag.

        </repeat>
      </repeat>
  </navigation>
</def>

Banjoey

unread,
Nov 2, 2011, 11:46:25 PM11/2/11
to Hobo Users
Ah ha ha ha ha ha!!!!

OK, so the problem I think is that I had moved the controller to the
admin site and forgot that I'd need a controller to define the :show
action. I'm so stupid. Thanks for pointing me to my mistake. I was
thinking "Well of course I have a show pa... oh crud..."

Thanks for the help on the DRYML. I have one question though. If I
remove the one if below it works great. If I keep it in there, it will
not render. I'm using the current pull from the git repo if that makes
a difference. It doesn't crash the page or anything, just doesn't show
the menu.

On Nov 2, 9:54 pm, kevinpfromnm <kevinpfro...@gmail.com> wrote:
> that seems like it should work as you have it.  do you have a show page for
> the posts controller?
>
> this is just minor suggestions to better use dryml's capacities for
> clearer/DRYer code:
>
> <def tag="ministry-nav">
>   <navigation class="ministry-nav" merge-attrs param="default">
>       <repeat with="&MinistryCategory.all" if>
> # the *if* tests for blankness of the current context if no condition is
> given and no need to set an instance variable if you're not using it again
> later
>         <h2 class="MinistryMenuCategories"><name/></h2>
>         <repeat:ministry_posts>
> # shorthand for *field="ministry_posts"*
Reply all
Reply to author
Forward
0 new messages