Skip to content

Commits

Commits on Dec 29, 2021

  1. Fix TypeScript linting

    Also upgraded to `@definitelytyped/dtslint`.
    jaylinski committed Dec 29, 2021
    Copy the full SHA
    a98b01c View commit details
    View at this point in the history
    Browse the repository at this point in the history

Commits on Feb 15, 2021

  1. [FEAT] Extract the Handlebars parser (#1713)

    Extracts the parser to `@handlebars/parser`, where it can be shared
    between different implementations. This means that e.g. Glimmer/Ember
    will be able to iterate on new features without forcing Handlebars to
    adopt them immediately, and vice versa. All implementors will be able to
    absorb changes as it makes sense for them.
    Chris Garrett committed Feb 15, 2021
    Copy the full SHA
    19bdace View commit details
    View at this point in the history
    Browse the repository at this point in the history

Commits on Mar 31, 2020

  1. chore: ignore external @types in tests

    - some indirect dependencies install @types packages which are not compatible with the older typescript.
    - adjusted test's tsconfig to not pick these up automatically, as the actual .d.ts does not depend on these external types.
    AviVahl authored and ErisDS committed Mar 31, 2020
    Copy the full SHA
    b440c38 View commit details
    View at this point in the history
    Browse the repository at this point in the history

Commits on Feb 4, 2020

  1. Copy the full SHA
    4de51fe View commit details
    View at this point in the history
    Browse the repository at this point in the history

Commits on Jan 10, 2020

  1. feat: default options for controlling proto access

    This commmit adds the runtime options
    - `allowProtoPropertiesByDefault` (boolean, default: false) and
    - `allowProtoMethodsByDefault` (boolean, default: false)`
    which can be used to allow access to prototype properties and
    functions in general.
    
    Specific properties and methods can still be disabled from access
    via `allowedProtoProperties` and `allowedProtoMethods` by
    setting the corresponding values to false.
    
    The methods `constructor`, `__defineGetter__`, `__defineSetter__`, `__lookupGetter__`
    and the property `__proto__` will be disabled, even if the allow...ByDefault-options
    are set to true. In order to allow access to those properties and methods, they have
    to be explicitly set to true in the 'allowedProto...'-options.
    
    A warning is logged when the a proto-access it attempted and denied
    by default (i.e. if no option is set by the user to make the access
    decision explicit)
    nknapp committed Jan 10, 2020
    Copy the full SHA
    7af1c12 View commit details
    View at this point in the history
    Browse the repository at this point in the history

Commits on Jan 8, 2020

  1. feat: access control to prototype properties via whitelist

    Disallow access to prototype properties and methods by default.
    Access to properties is always checked via
    `Object.prototype.hasOwnProperty.call(parent, propertyName)`.
    
    New runtime options:
    - **allowedProtoMethods**: a string-to-boolean map of property-names that are allowed if they are methods of the parent object.
    - **allowedProtoProperties**: a string-to-boolean map of property-names that are allowed if they are properties but not methods of the parent object.
    
    ```js
    const template = handlebars.compile('{{aString.trim}}')
    const result = template({ aString: '  abc  ' })
    // result is empty, because trim is defined at String prototype
    ```
    
    ```js
    const template = handlebars.compile('{{aString.trim}}')
    const result = template({ aString: '  abc  ' }, {
      allowedProtoMethods: {
        trim: true
      }
    })
    // result = 'abc'
    ```
    
    Implementation details: The method now "container.lookupProperty"
    handles the prototype-checks and the white-lists. It is used in
    - JavaScriptCompiler#nameLookup
    - The "lookup"-helper (passed to all helpers as "options.lookupProperty")
    - The "lookup" function at the container, which is used for recursive lookups in "compat" mode
    
    Compatibility:
    - **Old precompiled templates work with new runtimes**: The "options.lookupPropery"-function is passed to the helper by a wrapper, not by the compiled templated.
    - **New templates work with old runtimes**: The template contains a function that is used as fallback if the "lookupProperty"-function cannot be found at the container. However, the runtime-options "allowedProtoProperties" and "allowedProtoMethods" only work with the newest runtime.
    
    BREAKING CHANGE:
    - access to prototype properties is forbidden completely by default
    nknapp committed Jan 8, 2020
    Copy the full SHA
    d03b6ec View commit details
    View at this point in the history
    Browse the repository at this point in the history

Commits on Oct 28, 2019

  1. Add missing types for the Exception class properties (#1583)

    * Convert Exception to a class
    * Add node param type declaration
    * Test the types
    kabirbaidhya authored and nknapp committed Oct 28, 2019
    Copy the full SHA
    b8913fc View commit details
    View at this point in the history
    Browse the repository at this point in the history

Commits on Oct 27, 2019

  1. Add Handlebars.parseWithoutProcessing (#1584)

    When authoring tooling that parses Handlebars files and emits Handlebars
    files, you often want to preserve the **exact** formatting of the input.
    The changes in this commit add a new method to the `Handlebars`
    namespace: `parseWithoutProcessing`. Unlike, `Handlebars.parse` (which
    will mutate the parsed AST to apply whitespace control) this method will
    parse the template and return it directly (**without** processing
    😉).
    
    For example, parsing the following template:
    
    ```hbs
     {{#foo}}
       {{~bar~}} {{baz~}}
     {{/foo}}
    ```
    
    Using `Handlebars.parse`, the AST returned would have truncated the
    following whitespace:
    
    * The whitespace prior to the `{{#foo}}`
    * The newline following `{{#foo}}`
    * The leading whitespace before `{{~bar~}}`
    * The whitespace between `{{~bar~}}` and `{{baz~}}`
    * The newline after `{{baz~}}`
    * The whitespace prior to the `{{/foo}}`
    
    When `Handlebars.parse` is used from  `Handlebars.precompile` or
    `Handlebars.compile`, this whitespace stripping is **very** important
    (these behaviors are intentional, and generally lead to better rendered
    output).
    
    When the same template is parsed with
    `Handlebars.parseWithoutProcessing` none of those modifications to the
    AST are made. This enables "codemod tooling" (e.g. `prettier` and
    `ember-template-recast`) to preserve the **exact** initial formatting.
    Prior to these changes, those tools would have to _manually_ reconstruct
    the whitespace that is lost prior to emitting source.
    rwjblue authored and nknapp committed Oct 27, 2019
    Copy the full SHA
    62ed3c2 View commit details
    View at this point in the history
    Browse the repository at this point in the history

Commits on Oct 8, 2019

  1. Copy the full SHA
    0440af2 View commit details
    View at this point in the history
    Browse the repository at this point in the history

Commits on Sep 24, 2019

  1. add test for #1560

    nknapp committed Sep 24, 2019
    Copy the full SHA
    64ecb9e View commit details
    View at this point in the history
    Browse the repository at this point in the history
  2. Copy the full SHA
    93444c5 View commit details
    View at this point in the history
    Browse the repository at this point in the history
  3. Copy the full SHA
    d148d7c View commit details
    View at this point in the history
    Browse the repository at this point in the history
  4. Copy the full SHA
    2078c72 View commit details
    View at this point in the history
    Browse the repository at this point in the history

Commits on Sep 3, 2019

  1. fix typings of resolvePartial-options

    - derived from the object structure seen in the debugger
    
    closes #1534
    nknapp committed Sep 3, 2019
    Copy the full SHA
    888750e View commit details
    View at this point in the history
    Browse the repository at this point in the history
  2. Add "Handlebars.VM.resolvePartial" to type definitions

    - Handlebars.VM is actually not part of the API,
      but Handlebars.VM.resolvePartial is mentioned
      in the documentation and is thus now treated
      as part of the API.
    
    Closes #1534
    AndrewLeedham authored and nknapp committed Sep 3, 2019
    Copy the full SHA
    133b96a View commit details
    View at this point in the history
    Browse the repository at this point in the history

Commits on Aug 29, 2019

  1. feat: enhance typescript definition for knownHelpers

    - Add support for custom helpers while keeping
      the list of builtin-helpers to maintain for
      autocompletion support
    
    closes #1544
    nknapp committed Aug 29, 2019
    Copy the full SHA
    16572cd View commit details
    View at this point in the history
    Browse the repository at this point in the history

Commits on Mar 19, 2019

  1. Port over linting and test for typings

    - Move typings from lib/ to types/.
    - Add dtslint for validating types.
    - Use grunt-bg-shell to call out to dtslint during build step.
    timlindvall committed Mar 19, 2019
    Copy the full SHA
    3fb6687 View commit details
    View at this point in the history
    Browse the repository at this point in the history