flatiron / plates

Light-weight, logic-less, DSL-free, templates for all javascript environments!
MIT License
831 stars 69 forks source link

Better common.js support #96

Closed 3rd-Eden closed 11 years ago

3rd-Eden commented 11 years ago

Currently we do a common.js check that includes testing the existence of module.exports but this property is node specific and does follow the common.js modules specification.

This prevents common.js compliant environments such as Wakanda to use plates. An easy fix would be changing:

var Plates = (typeof module !== 'undefined' && typeof module.exports !== 'undefined' && typeof exports !== 'undefined') ? exports : {};

In to:

var Plates = (typeof module !== 'undefined' && typeof module.id !== 'undefined' && typeof exports !== 'undefined') ? exports : {};

The change here is to check against module.id instead of module.exports. The module.id is required by the common.js specification and exists in Node.js and other common.js environments.

edit Testing against a require.paths would not work either, as support for that has been removed in the current node versions.

daslicht commented 11 years ago

Just tested you modification in Wakanda and it is working ! Thank you very much !