Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Message from discussion <title>s and other non-component data
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Bryan Fink  
View profile  
 More options Nov 16 2007, 9:09 pm
From: Bryan Fink <bryan.f...@gmail.com>
Date: Fri, 16 Nov 2007 18:09:01 -0800 (PST)
Local: Fri, Nov 16 2007 9:09 pm
Subject: Re: <title>s and other non-component data
On Nov 16, 6:24 pm, David King <dk...@ketralnis.com> wrote:

> > - A while ago somebody asked a similar question and Bryan Fink
> > suggested returning a tuple of the form {title, Title} from the view
> > function, and then later picking up this tuple in the
> > html_container_controller and using its value to set the <title> tag.

> That does only take into account <title>s, and not any other  
> metadata. And doesn't using erltl preclude returning something useful  
> from a view function other than the data itself? And then the  
> component receiving the rendered page would have to walk the  
> resultant IOlist looking for it, rather than being able to pattern-
> match it. That just seems very brittle.

Yeah, it is a bit brittle.  But, some tips:

1. If you need to return several things for the container to find,
just use more tuples.  I have {title, X}, {head, X}, {onload, X}, etc.

2. ErlTl works just fine with this.  The code looks like:

<%@ index(Beer) %>
<% {title, ["BeerRiot - ", beer:name(Beer)]} %>
<% {head, <<"<script>...</script>">>} %>

3. My container controller picks each of these piece out using two
rules:
  a. all such tuples must be at the start of the rendered data
  b. all such tuples must be in a defined order

So, the container code looks roughly like:

index(Data) ->
    case Data of
        [{title, Title} | TData] -> ok;
        TData -> Title = "BeerRiot"
    end,
    case TData of
        [{head, Head} | HData] -> ok;
        HData -> Head = <<>>
    end
...
    {data, {Title, Head, OtherData}}.

I have to play a few more tricks, though, to account for newlines in
the rendered Data list.  That could be fixed by moving the ErlTl
statements all to one line, but it didn't seem important enough to
worry about.

So, that restricts using these tuples to the "top level" component
view, but it has worked pretty well for me so far.

The idea of adding a {meta, X} tuple to the list of things a
controller can return sounds interesting, but since this stuff is more
on the view side, it also seems a little out of place.  Not to say
that my hack isn't further out of place, of course.  ;)

-Bryan

P.S.  If you think the idea of a beer_controller is great, you'll love
that I also have a beer_container_controller, but only because I
couldn't decide among bottle_controller, can_controller, and
keg_controller.  :)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.