-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Prototypes #2
Comments
I really like this idea! I think the prototype-getter token will have to be something other than '+' though -- it would introduce too much ambiguity since we're already using it as the CSS sibling combinator. Thinking about it, the parser could just check, when you specify a selectorTag (e.g. div, header), whether or not a prototype is defined by that name. So we don't necessarily need an explicit operator to recall prototypes. It could be as simple as.
Outputting: <header><div class="foo bar"></div></header> What are your thoughts? |
Like the idea. And you're right about the However, what about scope? Would the following SIML…
…result in this… <img src="a" />
<img src="b" alt="" />
<img src="c" alt="" /> …or this? <img src="a" />
<img src="b" alt="" />
<img src="c" /> I'd opt for the latter; but would it be easy to implement in the parser? |
I agree -- the latter makes sense. Fortunately, it's too hard to handle scoping. |
I've begun implementation in the feature-prototype branch. It was surprisingly simple to implement. Feel free to check it out and play with test/resources/live-parser.html Next step is to write some tests. |
I like it, i like it a lot! |
Ok, it's now in the 0.3.2 release! :) Ready to play with here: http://padolsey.github.com/SIML/ Here's one of the chunks I've tested it with:
|
Works great! Also: Nice fix on the |
One of the greatest thing a preprocessor can do, is help better the authors writing experience: Less doing and more results.
This is why I propose adding a “prototype” like feature to SIML, a feature that allows authors to write concise code—writing certain selectors once, instead of multiple times.
Note: I’m not talking about mixins: Mixins are great too, but I’m seeing prototypes as an element, rather than “document fragment”, like feature.
Input
Setting prototypes:
/[A-Za-z][A-Za-z0-9_-]* = /
Getting prototypes:
/\+[A-Za-z][A-Za-z0-9_-]*/
Output
Final Notes
Sure, this is just a draft—the regexes are just an idea, I haven’t thought about what happens with multiple classes (in the prototype setting, and the prototype getting)—but “mixins” seem like a logical extension of an HTML preprocessor: One which I haven’t seen in HAML, Jade, Slim, and the like.
The text was updated successfully, but these errors were encountered: