Skip to content
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

Support single quoting for attributes (on element basis) #74

Open
nightswimmings opened this issue Jan 20, 2021 · 5 comments
Open

Support single quoting for attributes (on element basis) #74

nightswimmings opened this issue Jan 20, 2021 · 5 comments

Comments

@nightswimmings
Copy link

nightswimmings commented Jan 20, 2021

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;)

@fmcarvalho
Copy link
Member

fmcarvalho commented Jan 20, 2021

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?

@nightswimmings
Copy link
Author

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
Copy link
Member

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

@fmcarvalho
Copy link
Member

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?

@lcduarte
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants