Home About The Codist RSS Feed

Building a Web Framework My Way - A new direction
Oct 04, 2006 15:30 perm link Readers: 295

OK, the XML-naysayers have won, I decided to take a different direction completely.

The main issue is to mash html and enough framework detritus together to form something dynamic. Every framework takes a different tack, from putting the code into the html and ignoring validation (asp, php etc.) to being subtle (wicket). I thought about it for while and decided to look at including the html in the framework detritus instead of the other way around. Currently it's looking like an odd programming language (see below). I have considered using something like lisp; the ideal I want though requires that I can evaluate this in both the server and the client, which means writing an evaluator in both java and javascript. I'm not sure writing a lisp interpreter in javascript is much fun. In any case I am not a big fan of lisp at this point.

This "language" is rather easy to parse and syntax color (not as easy as xml though) and similiar enough to html. Even thought it is not html it can be embedded (for example inside a div tag) without affecting XHML validation. I can also create web pages with nothing more than a textarea and the interpreter and have a live preview.

Maybe it will work out or fail, it's just a step on the path. This example below is a realization of the blog page you are looking at.

html[
head[
  title[]
  css[/static/base.css]
]

body[
  div(container)[
    div(header)[
      h1[{blog.title}]
      h3[{blog.subtitle}]
    ]
    div(wrapper)[
      div(content)[
        loop{post|articles}
        [
          h4(article)[{post.title} span[{post.time}]]
          div[{post.content}]
          if{post.hascomments}
          [
            loop{i | post.comments}
            [
              div[{i.comment}]
            ]
          ]
        ]
      ]
    ]
    div(navigation)[
      h4[Home]
        li[url[Home|{blog.homeurl}]]
      h4[Tags/RSS]
        li[url[RSS|{blog.rssfeed}] img[rss.png]]
      h4[Recent posts]
      ul[
        loop{i | recentposts}
        [
          li[url[{i.truncatedtitle}|{i.permurl}] {i.time}]
        ]
      ]
      h4[Recent comments]
      ul[
        loop{i | recentcomments}
        [
          li[url[{i.truncatedcomment}|{i.permurl}] {i.time}]
        ]
      ]
    ]
    div(extra)[]
    div(footer)[
      p[contents copyright © 2006 by andrew wulf ♦ email codist at biit dot com ♦ arlington, texas,
      usa br[] check out my cd at url[consonance music|http://consonancemusic.com]]
    ]
  ]
]]

My Tags:

Name:


Optional URL:


Comment:


Save Cancel

Copyright © 2007 By Andrew Wulf