Minor adjustments needed to make the TypeScript compiler
that is built into Deno, be happy with how mustache.js'
ES module source looks in terms of function parameters
passed and object mutability.
Refs https://github.com/phillipj/mustache.js/pull/1
As part of transition the source code to be a proper plain ES module,
we're removing the handcrafted UMD wrapper around the source code.
This means the UMD wrapper will have to come from elsewhere; a build
step introduced later.
In an effort of moving with recent changes in Node.js and its built-in
support for ES modules, we're making the main source code reside inside
`mustache.mjs`. This will also allow Deno users to use this package as
an ES module directly by importing `mustache.mjs`.
An ES3 / UMD version of the source code is still planned to exist in
`mustache.js`, but will involve a build step to transform the ES module
source into a plain .js version.
By renaming the file *before* changing any contents, git will
recognise the file has been renamed and therefore allows us to see all
historical changes to the old .js source code with the `--follow` argument:
```
$ git log --follow -- mustache.mjs
```
Without ensuring git sees this is a file rename, we will in practise
loose the old source code's history, or at least make it quite weird
and less intuitive to find. That's not fair to the historical
contributors and in general getting hold of a well documented log of
changes to a file in git, is extremely valuable in those few scenarios
where it's *really* needed.
This small change fixes the output of functions used in partials with
indentation. Bug reports has shown that the functions output is shifted
with the amount of indentation the partial has.
The bug itself is best illustrated in the tests added in 621ae80652.
Closes https://github.com/janl/mustache.js/issues/712
* prevent value from being returned by Context.prototype.lookup if lookupHit is false
* add test for renderability of Array.length via dot notation
* Remove `typeof obj === 'object'` constraint in prop lookup
Allows rendering properties of primitive types that are not objects, such as a string.
* pop lookup needs to use hasOwnProperty for non-objs
* re-add constraint in prop lookup, but make property lookups for primitives possible through dot notation
* add test to address #589 specifically
* enhance readability of primitiveHasOwnProperty and add comments to explain why it is used in one case but not the other
Pull requests #643 and #664 together fix the issue reported in issue #617, but the change in behavior is causing semvers concerns. See issue #669. Therefore, roll back #643 and #664 and later reintroduce in next planned major release (v3.0).
Fixes#669
When using amdclean to create a footprint less javascript file, the object needs to be returned to let it properly be assigned to the created script variable.
As we require the template to be a `string` we now throw an error when given
any other data type. This should provide the developers with a meaningful
error rather than a cryptic TypeError from the murky depths of our source code.
Fixes#464