Open benpate opened 2 years ago
i like I am a Dismissable(val:42)
or something like that
One issue with that is that we need to make I
a feature start
Yeah, and that seems problematic, especially when "i" is such a commonly-used variable name. You all know I'm not a parser/compiler designer, but wouldn't that break all kinds of stuff in the grammar? Let me know if I'm wrong about this, but it's why I'm looking for alternatives in the grammar, such as "use", or out of the grammar, such as another custom attribute.
What about "make"? It's close to the English usage of the word, and we're already using this token in a loosely similar context.. Saying make me Dismissible()
reads nicely, and follows the "verb"-ness of other _hyperscript commands.
<humor>
Or, if we're really commited to "I am", it would be hillarious (but probably confusing) to branch out to other languages...
what about Spanish? soy Dismissible()
or French? je suis Dismissible()
or (in honor of Deniz) Turkish? Ben Dismissible()
<- I'm partial to this for obvious conflict-of interest reasons ;)
</humor>
In all seriousness, it's not the end of the world to leave it as is, but "install" just doesn't read nicely to me. I'll keep digging, and hopefully we can come up with something that reads nicely, and is easily parseable.
The more I think about this, the more I feel like behaviors should be addressed by URL. Current behaviors break LoB by being global variables.
2 cents: not all behavior names naturally end in "able" .. as in draggable
, e.g. we have some behaviors where we string a long a few different event handlers that isn't entirely related... coming up with a behavior name for those are hard, we just cal them xxxHandler
.
So on that basis, soft downvote from me on the "I am" syntax.
Also... I'm not sure if you can mix installing behaviors and normal hyperscript in the same _="..."
attribute at the moment.
If not, then perhaps the use="..."
syntax could be useful to allow you to mix behaviors along with regular hyperscript on the same element
Also... I'm not sure if you can mix installing behaviors and normal hyperscript in the same _="..." attribute at the moment.
You can.
_="
install Draggable(handle: .titlebar in me)
on mouseover ...
on draggable:stop ...
"
Hyperscript's behaviors are a wonderful thing, but instantiating them on an element always reads a little funny. @dz4k has promoted
I am
as an alias for theinstall
command, as in<span data-script="I am Inevitable(val:42)"></span>
. While this reads wonderfully, it could certainly be trouble for the parser. Here are two alternatives to consider:"Use"
We're not currently using the keyword
use
, and it seems to fit semantically, as in:Distinct Attribute
Since this is such a DOM-speciic feature, it might work well to separate it into its own attribute -- something like:
or even
Thoughts?