views:

53

answers:

1

Something that's really bothered me about XHTML, and XML in general is why it's necessary to indicate what tag you're closing. Things like <b>bold <i>bold and italic</b> just italic</i> aren't legal anyways. Thus I think using {} makes more sense. Anyway, here's what I came up with:

doctype;
html
{
head
{
  title "my webpage"
javascript '''
// code here
// single quotes do not allow variable substitution, like PHP
// triple quotes can be used like Python
'''
}
body
{
  table {
     tr {
        td "cell 1"
        td "cell 2"
        td @var|filter1|filter2:arg
     }
  }
  p "variable @var in a string"
  p "variable @{var|withfilter}"
  input(type=password, value=secret); // attributes are specified like this
  br; // semi-colons are used on elements that don't have content
  p { "strings are" "automatically" "concatenated together" @andvars "too" }
}
}

Tags that only contain one element do not need to be enclosed in braces (for example td "cell 1" the td is closed immediately after the text). Strings are outputted directly, except double-quoted strings allow variable substitution, and single quotes do not. I'm adopting a filtering scheme similar to Django's. The thing I'm most concerned about, I think, is variable substitution in double-quotes.. I don't want people to have to open and close single quotes everywhere because the syntax things are being treated as vars that shouldn't. I don't think the @ character is very commonly used in code. I was going to use $ like PHP, but jQuery uses that, and I want to allow people to do substitutions in their JS too (of course, if they don't need to, they should use single quotes!)

Templates will use "dictionaries". By default, it uses this HTML dict, with familiar tags, but you can easily add your own. "Tags" may consist of not just one, but multiple HTML tags.

Still need to decide how to do loops and including partials...

Edit: Started an open source project, for those interested.

+2  A: 

I believe you can get close to that with the syntax of TCL script language.

The thing I like the most about your idea is the removal of the (to me very) redundant information in the closing tags of the (has it's roots in) SGML markup.

Another clean option IMO is to go the road of using indenting to specify scope, eliminating braces all together. With the assumption of a little editor support, I can imagine this happening.

I think it's possibly stiflling that globally used specifications cater to the theorhetical person using VI or Notepad to type out their markup...

Gabriel
Good point... maybe I should keep the HTML spec as a "base" and only allow add-ons, but not removing or replacing tags altogether? I'll take a peek at TCL.. don't think I've heard of that.
Mark