xmlet/HtmlFlow

Support single quoting for attributes (on element basis)

nightswimmings opened this issue · 5 comments

It would be nice being able to tell whether serializing the quotes as single like in:

<div data='{"a":"b"}'>
since those are legal in html

(To avoid hundreds of &quot;)

I see your point. Can we simply change double quotes by single quoting?

Will be there the chance of some developer require double quotes? In that case, should we support some how both options?

I dislike configurations. But if we have to...

@lcduarte What do you think about it?

Can I simply change the character here https://github.com/xmlet/HtmlFlow/blob/master/src/main/java/htmlflow/Tags.java#L40

This is only used in printAttribute and appendAttribute, if I am not wrong.

Will we have complains of other guys in the future?

To be honest, I think 99 % of users would hate if the default switched to single quote. But perhaps an extra optional param on the attributes flow builder would not disturb :p

@lcduarte What do you think about it?

I think the only way to make everyone happy is to add an option on DynamicHtml.view to receive an optional parameter Supplier<HtmlVisitorCache>. This way everything stays the same for everyone else and we give the chance for people like @nightswimmings to provide their own implementation of the HtmlVisitorCache, in this case replacing the double quotes for single quotes.

I am now planning to handle this issue for next release and I guess that is simpler and more effective to chose what kind of quotation to use (i.e. single or double) through properties. Then the end user programmer may choose single quotation by running Java with -Dhtmlflow.quotation=single or providing a resource properties file htmlflow.properties.

Simpler than requiring a new implementation of HtmlVisitorCache. @lcduarte what do you think about it?

Looks like the right choice. We keep the default value as it was until this change and give the possibility of customizing it from now on.