Comments (10)
All libraries generally use at least one object in the global namespace. Its perfectly acceptable for an application to have a few variables in the global namespace, since the application developer has oversight into the involved components.
Conversely, it is potentially dangerous for a library to increase the surface area of the global namespace, since a library author has no idea what other variables will already be there. The constructor Plates
is a pretty safe name.
from plates.
Okay, maybe the topic name is not correctly chosen.
My problem is that you are mixing node specific code with that global variable creation. And when you use a tool like browserify to include plates, you lose plates in the wrapping it creates.
This is a case where Plates should export on exports, but process is not defined.
Please use:
;var Plates = !exports ? {} : exports;
or
;var Plates = (!module && !exports) ? {} : exports;
Reopen!
from plates.
The problem with this is that its far too likely for exports
or module
to be defined in the user's global namespace. Alternatives?
from plates.
At include time? That sounds like some pretty bad style of polluting the global namespace, who does that? Ofc my proposal is not idiotproof.
;var Plates = (typeof require == 'function' && module && exports) ? exports : {};
from plates.
I think we are crossing wires. I am talking about the client side. The client side it is very easy for someone to have those variables defined. Of course its bad style, but its more likely than an object named process with a property called title. Someone can also have a client side function called require
... Let's think about it some more.
from plates.
Well IMO using Plates and having a require function and module and exports objects is basically as unlikely as having a process object with a title containing "node". Also this risk is far less important than the drawback it has.
An alternative way to go would be giving out different files for browser and nodejs use.
Let's think about it some more.
Why isn't this open then?
from plates.
A library that exports a single global object does not polluting the global namespace. If you are concerned about browserify please create a test that demonstrates the issue.
from plates.
It's pretty simple what browserify does:
warp a function around Plates
function(require, module, exports, __dirname, __filename) {
var Plates = {}
[...]
}
execute the function -> oh noes, Plates got garbage collected.
I think I'm just going to fork Plates and stop annoying you.
from plates.
I know what browserify does, i asked you to write a test for it. If you cant make a tangible case for your issue i cant help.
from plates.
I don't really have any idea how a test for this should look like.
from plates.
Related Issues (20)
- .append() or .partial doesn't work with inputs HOT 1
- Partials HOT 1
- Tests failing on latest Node.js HOT 1
- State of this library HOT 3
- Overrides elements with bad content HOT 2
- Plates (fork?) with some DSL HOT 1
- Collection iteration HOT 1
- Binding doesn't work as expected HOT 1
- Question, not Issue: Getting the innerHTML of a tag for multi-language support
- Not able to get the correct HTML output
- BUG: "Template" may not contain "Subtemplates" tag name HOT 1
- Old Version on Bower HOT 1
- Example project with template nesting HOT 1
- Mapping the same partial multiple times with collections example
- Map to a valueless attribute
- Multiple clauses does not render correctly HOT 2
- Option to allow/disallow undefined attributes HOT 1
- Better common.js support HOT 1
- Provide a proper way to avoid XSS attacks
- Problem with function compileMappings, and how i (might have) fixed it.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plates.