Closed miohtama closed 12 years ago
We'll, e.g., Spine.js, jQuery, Handlebars.js and YUI export a global object containing constructors and functions. Only Yahoo has adopted usage of all caps, which is indeed, ugly :)
Transparency now exports one global object, Transparency, working as a namespace.
At the moment, it contains just one function, Transparency.render(). In the future, at least it contains additionally at least Transparency.SafeHtml() to construct unescaped strings.
jQuery plugin code is executed only if jQuery is available, so it can be included all the time. Other frameworks could be easily supported in a similar fashion. Would you like to contribute? =)
Please use lowercase for namespace and CamelCase for classes. If Transparency is indeed a module then it should be all lower.
Also I think it would be more future proof to have safeHTML() as function, not constructor, as in the future the internal implementatino may change (to something more efficient),
Clarification: in Javascript use CamelCase for constructor.
So either new Transparency()
or transparency
Unfortunately I don't personally use other major frameworks besides jQuery :)
Closing as there hasn't been requests for any specific framework. I'll add the boilerplate, if someone requests something specific in the future.
To continue with issue #10
Please use UGLY full caps for globals: TRANSPARENCY (only if you are going to make it a forced global)
http://yuiblog.com/blog/2006/06/01/global-domination/
E.g. Three.js, Yahoo YUI does this and it is generally accepted best practice:
https://github.com/mrdoob/three.js/blob/master/src/Three.js
However, since globals are not that popular, I suggest you add minimal boilerplate to export Transparency in different ways
I found an example: Mustache for Javascript does this
https://github.com/janl/mustache.js/tree/master/wrappers
Is Transparency a class or a namespace?