jsguy / mithril.sugartags

Sugar for mithril templating system
MIT License
20 stars 1 forks source link

the casing of sugartags #2

Closed icylace closed 10 years ago

icylace commented 10 years ago

Why are the sugartags all uppercase? I think they should be lowercase because:

  1. All uppercase is a common naming convention for constants in most coding style guides.
  2. Camel casing is also a common naming convention for functions and methods in many coding style guides.
  3. Most if not all modern HTML formatting is done with lowercase tags and attributes. Having lowercased sugartags would look more like what one would expect to see when viewing HTML source.
  4. I don't believe any tag in the HTML spec is named the same as a JavaScript reserved word so using lowercase naming for the sugartags should cause no naming collisions.
jsguy commented 10 years ago

They are uppercase so they are unlikely to conflict with local variable names, the tag list is fairly long:

["A","ABBR","ACRONYM","ADDRESS","AREA","ARTICLE","ASIDE","AUDIO","B","BDI","BDO","BIG","BLOCKQUOTE","BODY","BR","BUTTON","CANVAS","CAPTION","CITE","CODE","COL","COLGROUP","COMMAND","DATALIST","DD","DEL","DETAILS","DFN","DIV","DL","DT","EM","EMBED","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","FRAME","FRAMESET","H1","H2","H3","H4","H5","H6","HEAD","HEADER","HGROUP","HR","HTML","I","IFRAME","IMG","INPUT","INS","KBD","KEYGEN","LABEL","LEGEND","LI","LINK","MAP","MARK","META","METER","NAV","NOSCRIPT","OBJECT","OL","OPTGROUP","OPTION","OUTPUT","P","PARAM","PRE","PROGRESS","Q","RP","RT","RUBY","SAMP","SCRIPT","SECTION","SELECT","SMALL","SOURCE","SPAN","SPLIT","STRONG","STYLE","SUB","SUMMARY","SUP","TABLE","TBODY","TD","TEXTAREA","TFOOT","TH","THEAD","TIME","TITLE","TR","TRACK","TT","UL","VAR","VIDEO","WBR"],

So there'd be a good chance of a local variable name collision somewhere along the line... Better safe than sorry!

Uppercase also stands out a little more - lowercase tends to blend into the code a little...

icylace commented 10 years ago

I'll have to disagree but I appreciate your reasoning.

How about adding an option to do it? Maybe a person like me could add something like:

m.sugarTags.setup({ case: 'lowercase' });

to the initialization phase of their code.

A setup method also leaves the door open for adding features in a sensible way (e.g. activating SVG tags when they're needed).

jsguy commented 10 years ago

Yes, that sounds reasonable, I'll add a feature for that

icylace commented 10 years ago

Thanks !

jsguy commented 10 years ago

Ok I've added the ability - do:

with(m.sugarTags.lower()){ ...

To use it.

icylace commented 10 years ago

Thanks !