HtmlFlow icon indicating copy to clipboard operation
HtmlFlow copied to clipboard

Support single quoting for attributes (on element basis)

Open nightswimmings opened this issue 5 years ago • 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;)

nightswimmings avatar Jan 20 '21 12:01 nightswimmings

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?

fmcarvalho avatar Jan 20 '21 13:01 fmcarvalho

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

nightswimmings avatar Jan 20 '21 21:01 nightswimmings

@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.

lcduarte avatar Jan 20 '21 22:01 lcduarte

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?

fmcarvalho avatar Apr 09 '21 14:04 fmcarvalho

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.

lcduarte avatar Apr 13 '21 13:04 lcduarte