Stencil v0.8.0 Release Notes

Release Date: 2017-02-18 // about 7 years ago
  • 💥 Breaking

    • It is no longer possible to create Context objects. Instead, you can pass a dictionary directly to a Templates render method.
      - try template.render(Context(dictionary: ["name": "Kyle"]))
      + try template.render(["name": "Kyle"])
    
    • Template loader are no longer passed into a Context, instead you will need to pass the Loader to an Environment and create a template from the Environment.
      let loader = FileSystemLoader(paths: ["templates/"])
    
      - let template = loader.loadTemplate(name: "index.html")
      - try template.render(Context(dictionary: ["loader": loader]))
      + let environment = Environment(loader: loader)
      + try environment.renderTemplate(name: "index.html")
    
    • Loaders will now throw a TemplateDoesNotExist error when a template is not found.

    • 🚚 Namespace has been removed and replaced by extensions. You can create an extension including any custom template tags and filters. A collection of extensions can be passed to an Environment.

    ✨ Enhancements

    • 🔧 Environment is a new way to load templates. You can configure an environment with custom template filters, tags and loaders and then create a template from an environment.

    Environment also provides a convenience method to render a template directly.

    • FileSystemLoader will now ensure that template paths are within the base path. Any template names that try to escape the base path will raise a SuspiciousFileOperation error.

    • 🆕 New {% filter %} tag allowing you to perform a filter across the contents of a block.

      {% filter lowercase %}
        This Text Will Be Lowercased.
      {% endfilter %}
    
    • You can now use {{ block.super }} to render a super block from another {% block %}.

    • Environment allows you to provide a custom Template subclass, allowing new template to use a specific subclass.

    • If expressions may now contain filters on variables. For example {% if name|uppercase == "TEST" %} is now supported.

    🗄 Deprecations

    • 🗄 Template initialisers have been deprecated in favour of using a template loader such as FileSystemLoader inside an Environment.

    • 🗄 The use of whitespace inside variable filter expression is now deprecated.

      - {{ name | uppercase }}
      + {{ name|uppercase }}
    

    🐛 Bug Fixes

    • ⏪ Restores compatibility with ARM based platforms such as iOS. Stencil 0.7 introduced compilation errors due to using the Float80 type which is not available.