Re: Euphoria MVC framework - template parser online

new topic     » goto parent     » topic index » view thread      » older message » newer message
euphoric said...

I've only recently (last few years) been using a MVC paradigm for development of web apps. It seems you are putting Controller functionality into View space. Or is it reasonable/appropriate here?

You're not wrong that it's unusual and inappropriate to put controller logic into the view. But that's not what I'm doing and that's not the intent for template functions.

The immediate goal was to provide a simple way to fetch model properties in a "Euphorian" way. Euphoria doesn't natively have dot notation, but it does have functions.

I will add dot notation soon. I do believe that will be a cleaner and simpler way to display models (which are just maps) in the views.

The overall intent for template functions is to provide a way for the view to alter the display of the model without altering the model itself.

Here's an example of adding some basic formatting to the view via functions:

function mailto_link( object text ) 
    return sprintf( "<a href='mailto:%s'>%s</a>", {text} ) 
end function 
add_function( "mailto_link", {"text"} ) 
 
function title_case( object text ) 
    return text:proper( text ) 
end function 
add_function( "title_case", {"text"} ) 

    {% for user in user_list %} 
    <tr> 
        {# all of this whitespace will be ignored... #} 
        <td>{{              user.id              }}</td> 
        <td>{{  title_case( user.first_name )    }}</td> 
        <td>{{  title_case( user.last_name )     }}</td> 
        <td>{{ mailto_link( user.email_address ) }}</td> 
        <td>{{  title_case( user.job_title )     }}</td> 
        <td>{{              user.ip_address      }}</td> 
    </tr> 
    {% end for %} 

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu