www.webdeveloper.com
Results 1 to 14 of 14

Thread: Off-side-rule and HTML

  1. #1
    Join Date
    Jan 2011
    Location
    Munich, Germany
    Posts
    232

    Off-side-rule and HTML

    I would like to introduce a small domain specific language that introduces the off-side-rule to HTML (http://en.wikipedia.org/wiki/Off-side_rule), somewhat like this:

    <body><h1>Purpose</h1>
    <...more HTML...>
    command1 argument1 argument2
    switch1 more parameters
    switch2 more parameters

    <...more HTML...>
    command2 argument1 argument2 argument3
    switch1 more parameters

    </body>

    So I intend to insert my DSL code "in between" the HTML of the body, without tagging it as is customary in PHP.

    However, as a constraint, this only is used in conjunction with a Javascript file included in the header.

    The purpose of the DSL is to enable the user to write much more cryptive and fast syntax, that may also stand for Javascript or even PHP/Java/Python etc. bits.

    Questions:

    - Is this a new idea, or have many people had the same?
    - What are the arguments (for and) against introducing the off-side-rule to HTML?


    Thanks in advance
    http://4nf.org/ - Ajaxify jQuery plugin

  2. #2
    Join Date
    Aug 2010
    Location
    San Diego
    Posts
    242
    So you're making a new language. It seems very, very tricky to try and embed this in HTML without bracketing it (like PHP does with <?... ?>).

    But if it is bracketed, I don't see any problem using off-side-rule syntax for the new language.

  3. #3
    Join Date
    Jan 2011
    Location
    Munich, Germany
    Posts
    232
    Thanks very much!

    Is it just impolite not to use brackets like PHP or are there other reasons not to?
    http://4nf.org/ - Ajaxify jQuery plugin

  4. #4
    Join Date
    Aug 2010
    Location
    San Diego
    Posts
    242
    Quote Originally Posted by arvgta View Post
    Is it just impolite not to use brackets like PHP or are there other reasons not to?
    With some sort of brackets (or block delimiters), it's easier to specify the syntax of how the various languages on the page are intertwined. You need to specify the syntax of the page in order to build a parser for it. Without brackets it might be impossible to specify a syntax, or the syntax (and the parser/preprocessor) might be horrendously complex.

  5. #5
    Join Date
    Jan 2011
    Location
    Munich, Germany
    Posts
    232
    Hi Handcraftedweb,

    I understand. Yes, that would be difficult to parse (without any kind of hooks).

    I was thinking of using "\n|" as a unique delimiter.
    (the new code is supposed to be pleasant to the eye)

    How often do you think "\n|" occurs naturally in contemparary HTML?

    (the user would additionally be self-responsible for avoiding clashes, by e.g. inserting a blank in existing HTML)
    http://4nf.org/ - Ajaxify jQuery plugin

  6. #6
    Join Date
    Aug 2010
    Location
    San Diego
    Posts
    242
    Quote Originally Posted by arvgta View Post
    How often do you think "\n|" occurs naturally in contemparary HTML?
    I don't know. You'd need to ask someone that really understands the syntax of the various HTML dialects, someone that has written an HTML parser or two.

  7. #7
    Join Date
    Jan 2011
    Location
    Munich, Germany
    Posts
    232
    Thanks anyway!

    I think it'll do the job - checking for a line break and then a "|" as first character on the line(s) that is to be interpreted.
    http://4nf.org/ - Ajaxify jQuery plugin

  8. #8
    Join Date
    Aug 2010
    Location
    San Diego
    Posts
    242
    Oh so you're talking about code like this:
    HTML Code:
    <html>
    <div><h1>Header</h1></div>
    |Some code
    |   In some new
    |       language
    |to be preprocessed
    <div>some more html</div>
    </hml>
    My guess is that will work without much difficulty.

  9. #9
    Join Date
    Jan 2009
    Posts
    3,346
    I can't imagine that will be easier to type than a single block opening and closing as in other languages (such as PHP, JSP, ASP, etc). There are very good reasons all of those very popular languages use almost identical block identifiers, maybe take a few moments to read the html spec sheet so you can fully grasp what impact your "adjustments" might make to parsers.

  10. #10
    Join Date
    Jan 2011
    Location
    Munich, Germany
    Posts
    232
    Hi!

    What if the block were introduced just only by a newline character, outside of HTML? I could check in PHP for orphanated text nodes with the DOMDocument class...

    Something like:

    <html>
    <div><h1>Header</h1></div>
    Some code
    In some new
    language
    to be preprocessed
    <div>some more html</div>
    </hml>

    Thanks handcraftedweb - glad you think the approch with the "\n|" would be feasible. What do you think of the above?
    http://4nf.org/ - Ajaxify jQuery plugin

  11. #11
    Join Date
    Jan 2009
    Posts
    3,346
    Quote Originally Posted by arvgta View Post
    Hi!

    What if the block were introduced just only by a newline character, outside of HTML? I could check in PHP for orphanated text nodes with the DOMDocument class...

    Something like:

    <html>
    <div><h1>Header</h1></div>
    Some code
    In some new
    language
    to be preprocessed
    <div>some more html</div>
    </hml>

    Thanks handcraftedweb - glad you think the approch with the "\n|" would be feasible. What do you think of the above?
    That would break html parsers and fail html validation.

  12. #12
    Join Date
    Jan 2011
    Location
    Munich, Germany
    Posts
    232
    Hi criterion9,

    I'm thinking of including these text nodes within a master <div>.
    That way, they would validate and be loose text nodes...

    Handcraftedweb - what do you think?
    http://4nf.org/ - Ajaxify jQuery plugin

  13. #13
    Join Date
    Aug 2010
    Location
    San Diego
    Posts
    242
    Quote Originally Posted by arvgta View Post
    Hi criterion9,

    I'm thinking of including these text nodes within a master <div>.
    That way, they would validate and be loose text nodes...

    Handcraftedweb - what do you think?
    I'm assuming you're preprocessing this on the server side, in which case the input doesn't need to be valid HTML, the output does. The input does need to have well specified language/syntax and the preprocessor will act as validator for the new language.

    So you don't need the enclosing div but I guess it wouldn't hurt.

  14. #14
    Join Date
    Jan 2011
    Location
    Munich, Germany
    Posts
    232
    Thanks Handcraftedweb!

    It's a mixture of client-side and server-side processing...
    (see. http://4nf.org/n.js)

    Worth mentioning that the wrapping <div> is visible to the user(on display HTML) and the search engine alike from the start, as they see the HTML before DOMReady.

    So if I want it to validate, I do need the wrapping <div> .

    Am now thinking of integrating JQuery into the framework (http://4nf.org/)

    Can anybody think of how the off-side-rule could be used to further simplify the use of JQuery in a pre-processing step (server-side)?

    For example, I could think of introducing:

    Code:
    f()
         ...
         ...
    instead of:

    Code:
    function() {
         ...
         ...
    }

    Any other ideas?


    Thanks!
    http://4nf.org/ - Ajaxify jQuery plugin

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles