SitePoint Sponsor

User Tag List

Page 3 of 3 FirstFirst 123
Results 51 to 62 of 62

Thread: templated if's

  1. #51
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees
    I think this depends on your approach. In GUI MVC, the controller and view are neccesarily intertwined and could be considered a single layer, whereas in Sun's Model 2 architecture (which I believe is the first use of MVC for the web?), the Controller (servlets) and the View (jsp) are more distinct. So it's not really a confusing point; either way can be considered 'real' MVC, it's a detail of implementation.
    I think what you are describing there is differing degrees of separation between the View and Controller -- but still probably in the same layer. As I said, the Model-Presentation separation is the important one. How you provide separation (or if you do at all) within the Presentation layer is usually based on the needs of the application and your particular design style.
    Christopher

  2. #52
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lvismer
    Apologies for this seemingly silly question, but if you have a template and view-code, what code do you normally include in the view. Does it relate to logic related stuff that affects presentation. Perhaps some conditional stuff that you rather keep outside of the template, or maybe a different template to be used inside the view depending on some suttleties within the model?

    For my current purposes I have managed to get away with having a controller, model and template (which in my case is the view then). I am just exploring when one would actually need the combo of creating a view that incorporates template/s.
    I suppost the leanest View code that uses Templates would simply assign the values from the Model to the Template and then render. But that could be implicit if the Controller makes the Model data visible to the Template. That's simple and clean.

    More complex View code handles do more formatting of the data. An example would be server side generation of select, radio and checkboxes so that the values are selected.
    Christopher

  3. #53
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb

    What you can do, in regards to forms is to use a ViewHelper. The ViewHelper would manage the presentation for the FORM tag it's self, and have child ViewHelpers, one per FORM element.

    That way, each ViewHelper knows only about it's self, and everything is neat and tidy, in that there is only the one render() class method; That of the parent ViewHelper, which picks up on it's children.

    You could I suppose, consider it being a Composite, but the children are in effect, only leafs

  4. #54
    Non-Member lostseed's Avatar
    Join Date
    Sep 2005
    Location
    Zurconion Soon!
    Posts
    1,549
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arborint
    I get the impression from the various systems around that once you move past a simple template system that the best way to implement more complex templates (with logic) is to compile templates into PHP. This usually means some sort of XML compliant template because you will have the most tools available for parsing. Doing this gives designers something reasonable to work with and keeps them away from PHP (which is also a potential security risk). Since the complied templates are PHP the will be reasonably fast.

  5. #55
    SitePoint Wizard silver trophy
    beley's Avatar
    Join Date
    May 2001
    Location
    LaGrange, Georgia
    Posts
    6,117
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    A software program I use (ShopSite) uses bracketed tags in their templates which seems to work really well. I told my editor how to highlite the tags so I can easily see them inside an HTML document.

    Here's a list of their tags, which include If-Then statements, loops, etc.
    http://www.shopsite.com/help/8.0/en-...sheet.all.html

    Of course a lot of the tags are specific to the software program, but I really like the system they use. It was very easy to learn and apply in my page templates.

  6. #56
    SitePoint Guru
    Join Date
    Nov 2002
    Posts
    841
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    (Balance < 0) could also be represented as (IsOverdrawn), pushing the comparison into the domain logic. The template still needs a conditional construct.

    I think the more expressive the template language is, the more chance that the templates will end up with copy-pasted duplicate code. For example, the templates will be full of duplicated Balance < 0 conditionals. Thats because the template languages generally don't (and possibly shouldn't) go so far as to give template designers tools to promote logic reuse. To do so would make them full mini languages and you would probably be better of just using PHP as the templating language anyway.

    Another consequence of conditionals in templates is the issue of balancing HTML tags. With conditionals, your source template might not have balanced tags (or not be valid (X)(H)TML is some other way. In that case, how do you know that your output will be valid output if your templates need not be valid? The Kid templating language operates under this principle.

    I've never been a fan of footer templates that look like:
    Code:
       </body>
    </html>
    Which is why the WACT wrap tag was born.

    Recently, we've been doing some work on WACT that will require tags to be balanced. We're doing this partly because it makes parsing some other constructs far easier and partly just because it might be the right thing to do. When Ian made the change, he found several examples of unbalanced tags in the WACT examples.

    Perhaps the Rails guys are right about constraints.

  7. #57
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry

    Quote Originally Posted by Dr Livingston
    -BEEP- the Graphic Designers... They're at the very bottom of the food chain, but you are right about WYSIWYG editors...

    Some can be an absolute bast... to work with

    If it wasn't for the designer, the artist, there would be not be a website...thus, no site for the programmer...nor a job.

    Then again, I'm a programmer at heart to thrown in designer, photographer, and all round business guy to sell all these services to existing and prospective clients.

    Everyone has their respective job, it is insulting to put anyone on a sliding scale "food chain" dude.

    I'm not flaming, but, I don't like the IT guy that thinks "He might be the CEO, but I know Unix and can shut down his whole operation whenever I want, who has the power?"
    intragenesis, llc professional web & graphic design

  8. #58
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by holmescreek
    If it wasn't for the designer, the artist, there would be not be a website...thus, no site for the programmer...nor a job.
    I would take this one step further. If you as the programmer has done your job correctly the user/client should never really notice the system they are using. Past the system all they really care about is how pretty the website is. So to the people who really count (ie the client) the designer is top of the food chain and the programmer is the bottom of the food chain.

    I know for a fact that when I upgrade any website systems I do almost no one in the community says anything positive. No one says "Hey WOW! This is great" then only time I ever get any feed back is when something breaks. The designer however gets 5 page forum threads saying "WOW This looks fantastic, blah blah".

  9. #59
    SitePoint Wizard dreamscape's Avatar
    Join Date
    Aug 2005
    Posts
    1,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After mulling over this some more, I've actually changed my template engine to accept either imperative (HTML comment style) or declarative style syntax (valid xml/xhtml custom tags).

    Though since adding it in, I myself have some to favor the declarative style, I've got no plans to drop support for the imperative, since my whole motive behind adding declarative syntax support was to support both and let the template designer decide which syntax they prefer.

    And since templates are only re-compiled when they have been modified, the overhead associated with supporting both syntaxes is negligible.

    Though I've taken a bit different approach than most xml/xhtml style syntax I've seen. For example, one stated earlier in this thread which is a common approach is:

    <if test="foo==1">

    But what I've done is:

    <if var="foo" condition="equal" value="1">, which condition defaults to equal, so it can be simplified to <if var="foo" value="1">, which I personally find to be a little more XHTML like than having a test="..." attribute.

  10. #60
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dreamscape
    But what I've done is:

    <if var="foo" condition="equal" value="1">, which condition defaults to equal, so it can be simplified to <if var="foo" value="1">, which I personally find to be a little more XHTML like than having a test="..." attribute.
    That is fine for simple conditions. But what happens if you want to start creating more complicated if conditions. How would you describe something like:
    if (($var1 % $var2) == 0) :

  11. #61
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking

    Quote Originally Posted by OzRoy
    Past the system all they really care about is how pretty the website is.

    I disagree. All the customer cares about, when the job has been properly completed, is how much revenue is going to be generated from either sales (ecommerce) or referrals (informational site).

    As a web developer, programmer and photographer, all aspects of the site has to come together equally to produce a site that can meet the above requirements. And on the other hand, if you classify team members and "put them in their place" the network admin at the water cooler might have just overheard your board meeting and is now coating your CAT5 patch panel with beer and peanut butter. Then again..isn't the network admin at the VERY VERY bottom of the food chain?

    Ok, enough said. I think we got off topic on the thread. So, as professional courtesy, PM me OzRoy with any comments.

    For those of you following the thread, I apologize on my behalf from getting off topic. I'll watch my self in the future.
    intragenesis, llc professional web & graphic design

  12. #62
    SitePoint Enthusiast
    Join Date
    Jun 2005
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dreamscape
    But what I've done is:

    <if var="foo" condition="equal" value="1">, which condition defaults to equal, so it can be simplified to <if var="foo" value="1">, which I personally find to be a little more XHTML like than having a test="..." attribute.
    Your template system sounds nice, could you contribute with some of your template code? It would be really nice to see some more examples and how more complex templates could look like.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •