Re: emitting custom html5 elements from ionic

Jan Wielemaker <[email protected]> Tue, 22 Apr 2014 09:15:43 +0200
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
First of all, the OP claims that data-xyz(value) as an attribute still
works. This is more or less by accident, although we could hack it such
that specifically *data-* is defined to work this way as it
is defines by HTML5.  What goes wrong are custom *elements*.  Now, in
[1], we find:

"The W3C says you should not. It is bad practice.

    Authors must not use elements, attributes, or attribute values that
are not permitted by this specification or other applicable
specifications, as doing so makes it significantly harder for the
language to be extended in the future."

So I think we should not add quote-free support to the SWI-Prolog HTML
infrastructure.  We have seen
many work-arounds being proposed.  I think I mostly like simply using
'ion-list'(...) and use Carlo's
suggestion to write DCG rules around your commonly used ION constructs
to make them more readable.

A good alternative is to use quasi quotations.  The code below parses
just right.  This isn't
suitable for dynamically generated lists, where you typically want to
use the DCG facilities,
but there Carlo's suggesting will do the trick.

test -->
	html({|html||
	      <ion-list>
	        <ion-item ng-repeat="item in items" item="item">
	        </ion-item>
	      </ion-list>
	     |}).

	Cheers --- Jan

[1]
http://stackoverflow.com/questions/18177472/is-it-bad-practice-to-use-custom-elements-in-html5




On 04/22/2014 07:44 AM, Anne Ogborn wrote:
> I think I'd attack this by making a 'fix this' predicate
> that takes termerized html and looks for tag names with double underscore in them
> and emits the fixed version
>
> (forgive bugs, have not actually tried this)
>
> :- html_meta ix_html(html, ?, ?).
>
> ix_html(In) -->
>      {
>        ix(In, Out)
>      },
>      html(Out).
>
> %% ix(html, -) is det
>
> ix(In, Out) :-
>      ... bunch of messy code that looks for atoms that have double underscores in their names and replaces them with ones with minus signs.
>
> then replace all html//1 calls with ix_html//1 calls and use data__role for the code that dare not speak it's name.
>
> (or, if you're really desperate, do term expansion, in which case just fixing all atoms with middle position double underscores anywhere in code should do it).
>
> Alternatively, if you have many data-role type elements and use a-b=c infrequently, you could fix a-b to 'a-b' and not use the format-args notation.
>
> I haven't run into it enough to do this admittedly pretty heavy fix, but have found a few places where I was dinking with the browser specific version of properties where it would have been handy. Don't forget that things will have been module resolved by then, you need to handle module decorations properly.
>
> If there's one thing that keeps me a fan of Prolog it's the infinite malleability of the system. You can make it do what you need to, but generally you don't have to jump immediately to some macro world thingum, a la clojure.
>
> Whats needed here is a version of termerized html that is friendlier to custom properties with - in them. OK, we can make that.
>
> 8cD
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>