mustache/LICENSE000666 000000 000000 0000002237 13606207120011727 0ustar00000000 000000 MIT License Copyright (c) Microsoft Corporation. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE mustache/README.md000666 000000 000000 0000001134 13606207120012174 0ustar00000000 000000 # Installation > `npm install --save @types/mustache` # Summary This package contains type definitions for Mustache (https://github.com/janl/mustache.js). # Details Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mustache. ### Additional Details * Last updated: Fri, 10 Jan 2020 23:52:48 GMT * Dependencies: none * Global values: `Mustache` # Credits These definitions were written by Mark Ashley Bell (https://github.com/markashleybell), Manuel Thalmann (https://github.com/manuth), and Phillip Johnsen (https://github.com/phillipj). mustache/index.d.ts000666 000000 000000 0000020355 13606207120012624 0ustar00000000 000000 // Type definitions for Mustache 3.2.1 // Project: https://github.com/janl/mustache.js // Definitions by: Mark Ashley Bell , // Manuel Thalmann , // Phillip Johnsen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** * Provides the functionality to render templates with `{{mustaches}}`. */ interface MustacheStatic { /** * The name of the module. */ readonly name: string; /** * The version of the module. */ readonly version: string; /** * The default opening and closing tags used while parsing the templates. * * Different default tags can be overridden by setting this field. They will have effect on all subsequent * calls to `.render()` or `.parse()`, unless custom tags are given as arguments to those functions. * * Default value is `[ "{{", "}}" ]`. */ tags: OpeningAndClosingTags; /** * A simple string scanner that is used by the template parser to find tokens in template strings. */ Scanner: typeof MustacheScanner; /** * Represents a rendering context by wrapping a view object and maintaining a reference to the parent context. */ Context: typeof MustacheContext; /** * A Writer knows how to take a stream of tokens and render them to a `string`, given a context. * * It also maintains a cache of templates to avoid the need to parse the same template twice. */ Writer: typeof MustacheWriter; /** * Escapes HTML-characters. * * @param value * The string to escape. */ escape: (value: string) => string; /** * Clears all cached templates in this writer. */ clearCache(): void; /** * Parses and caches the given template in the default writer and returns the array of tokens it contains. * * Doing this ahead of time avoids the need to parse templates on the fly as they are rendered. * * @param template * The template to parse. * * @param tags * The tags to use. */ parse(template: string, tags?: OpeningAndClosingTags): any; /** * Renders the `template` with the given `view` and `partials` using the default writer. * * @param template * The template to render. * * @param view * The view to render the template with. * * @param partials * Either an object that contains the names and templates of partials that are used in a template * * -- or -- * * A function that is used to load partial template on the fly that takes a single argument: the name of the partial. * * @param tags * The tags to use. */ render(template: string, view: any | MustacheContext, partials?: PartialsOrLookupFn, tags?: OpeningAndClosingTags): string; /** * Renders the `template` with the given `view` and `partials` using the default writer. * * @param template * The template to render. * * @param view * The view to render the template with. * * @param partials * Either an object that contains the names and templates of partials that are used in a template * * -- or -- * * A function that is used to load partial template on the fly that takes a single argument: the name of the partial. */ to_html(template: string, view: any | MustacheContext, partials?: PartialsOrLookupFn): string; to_html(template: string, view: any | MustacheContext, partials?: PartialsOrLookupFn, send?: (result: string) => void): void; } /** * A simple string scanner that is used by the template parser to find tokens in template strings. */ declare class MustacheScanner { string: string; tail: string; pos: number; /** * Initializes a new instance of the `MustacheScanner` class. */ constructor(string: string); /** * Returns `true` if the tail is empty (end of string). */ eos(): boolean; /** * Tries to match the given regular expression at the current position. * * @param re * The regex-pattern to match. * * @returns * The matched text if it can match, the empty string otherwise. */ scan(re: RegExp): string; /** * Skips all text until the given regular expression can be matched. * * @param re * The regex-pattern to match. * * @returns * Returns the skipped string, which is the entire tail if no match can be made. */ scanUntil(re: RegExp): string; } /** * Represents a rendering context by wrapping a view object and maintaining a reference to the parent context. */ declare class MustacheContext { view: any; parentContext: MustacheContext | undefined; /** * Initializes a new instance of the `MustacheContext` class. */ constructor(view: any, parentContext?: MustacheContext); /** * Creates a new context using the given view with this context as the parent. * * @param view * The view to create the new context with. */ push(view: any): MustacheContext; /** * Returns the value of the given name in this context, traversing up the context hierarchy if the value is absent in this context's view. * * @param name * The name to look up. */ lookup(name: string): any; } /** * A Writer knows how to take a stream of tokens and render them to a `string`, given a context. * * It also maintains a cache of templates to avoid the need to parse the same template twice. */ declare class MustacheWriter { /** * Initializes a new instance of the `MustacheWriter` class. */ constructor(); /** * Clears all cached templates in this writer. */ clearCache(): void; /** * Parses and caches the given `template` and returns the array of tokens that is generated from the parse. * * @param template * The template to parse. * * @param tags * The tags to use. */ parse(template: string, tags?: OpeningAndClosingTags): any; /** * High-level method that is used to render the given `template` with the given `view`. * * @param template * The template to render. * * @param view * The view to render the template with. * * @param partials * Either an object that contains the names and templates of partials that are used in a template * * -- or -- * * A function that is used to load partial template on the fly that takes a single argument: the name of the partial. * * @param tags * The tags to use. */ render(template: string, view: any | MustacheContext, partials?: PartialsOrLookupFn, tags?: OpeningAndClosingTags): string; /** * Low-level method that renders the given array of `tokens` using the given `context` and `partials`. * * @param tokens * The tokens to render. * * @param context * The context to use for rendering the tokens. * * @param partials * The partials to use for rendering the tokens. * * @param originalTemplate * An object used to extract the portion of the original template that was contained in a higher-order section. * * If the template doesn't use higher-order sections, this argument may be omitted. */ renderTokens(tokens: string[], context: MustacheContext, partials?: PartialsOrLookupFn, originalTemplate?: string): string; } /** * An array of two strings, representing the opening and closing tags respectively, to be used in the templates being rendered. */ type OpeningAndClosingTags = [string, string]; /** * Whenever partials are provided, it can either be an object that contains the names and templates of partials that are used in tempaltes * * -- or -- * * A function that is used to load partial template on the fly that takes a single argument: the name of the partial. */ type PartialsOrLookupFn = Record | PartialLookupFn type PartialLookupFn = (partialName: string) => string | undefined /** * Provides the functionality to render templates with `{{mustaches}}`. */ declare var Mustache: MustacheStatic; export = Mustache; export as namespace Mustache; mustache/package.json000666 000000 000000 0000001757 13606207120013216 0ustar00000000 000000 { "name": "@types/mustache", "version": "3.2.0", "description": "TypeScript definitions for Mustache", "license": "MIT", "contributors": [ { "name": "Mark Ashley Bell", "url": "https://github.com/markashleybell", "githubUsername": "markashleybell" }, { "name": "Manuel Thalmann", "url": "https://github.com/manuth", "githubUsername": "manuth" }, { "name": "Phillip Johnsen", "url": "https://github.com/phillipj", "githubUsername": "phillipj" } ], "main": "", "types": "index.d.ts", "repository": { "type": "git", "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", "directory": "types/mustache" }, "scripts": {}, "dependencies": {}, "typesPublisherContentHash": "015a5118c0d0aaaba06745a822ac3d53d89608bc95fdc43596bc9f573b764f31", "typeScriptVersion": "2.8" }