vue-template-compiler

  • Version 2.7.16
  • Published
  • 584 kB
  • 2 dependencies
  • MIT license

Install

npm i vue-template-compiler
yarn add vue-template-compiler
pnpm add vue-template-compiler

Overview

template compiler for Vue 2.0

Index

Functions

function compile

compile: {
(
template: string,
options: CompilerOptionsWithSourceRange
): CompiledResult<ErrorWithRange>;
(template: string, options?: CompilerOptions): CompiledResult<string>;
};

    function compileToFunctions

    compileToFunctions: (template: string) => CompiledResultFunctions;

      function generateCodeFrame

      generateCodeFrame: (template: string, start: number, end: number) => string;

        function parseComponent

        parseComponent: (file: string, options?: SFCParserOptions) => SFCDescriptor;

          function ssrCompile

          ssrCompile: {
          (
          template: string,
          options: CompilerOptionsWithSourceRange
          ): CompiledResult<ErrorWithRange>;
          (template: string, options?: CompilerOptions): CompiledResult<string>;
          };

            function ssrCompileToFunctions

            ssrCompileToFunctions: (template: string) => CompiledResultFunctions;

              Interfaces

              interface ASTDirective

              interface ASTDirective {}

                property arg

                arg: string | undefined;

                  property modifiers

                  modifiers: ASTModifiers | undefined;

                    property name

                    name: string;

                      property rawName

                      rawName: string;

                        property value

                        value: string;

                          interface ASTElement

                          interface ASTElement {}

                            property alias

                            alias?: string;

                              property attrs

                              attrs?: { name: string; value: any }[];

                                property attrsList

                                attrsList: { name: string; value: any }[];

                                  property attrsMap

                                  attrsMap: Record<string, any>;

                                    property children

                                    children: ASTNode[];

                                      property classBinding

                                      classBinding?: string;

                                        property component

                                        component?: string;

                                          property directives

                                          directives?: ASTDirective[];

                                            property else

                                            else?: true;

                                              property elseif

                                              elseif?: string;

                                                property events

                                                events?: ASTElementHandlers;

                                                  property for

                                                  for?: string;

                                                    property forbidden

                                                    forbidden?: true;

                                                      property forProcessed

                                                      forProcessed?: boolean;

                                                        property hasBindings

                                                        hasBindings?: boolean;

                                                          property if

                                                          if?: string;

                                                            property ifConditions

                                                            ifConditions?: ASTIfCondition[];

                                                              property ifProcessed

                                                              ifProcessed?: boolean;

                                                                property inlineTemplate

                                                                inlineTemplate?: true;

                                                                  property iterator1

                                                                  iterator1?: string;

                                                                    property iterator2

                                                                    iterator2?: string;

                                                                      property key

                                                                      key?: string;

                                                                        property model

                                                                        model?: {
                                                                        value: string;
                                                                        callback: string;
                                                                        expression: string;
                                                                        };

                                                                          property nativeEvents

                                                                          nativeEvents?: ASTElementHandlers;

                                                                            property ns

                                                                            ns?: string;

                                                                              property once

                                                                              once?: true;

                                                                                property onceProcessed

                                                                                onceProcessed?: boolean;

                                                                                  property parent

                                                                                  parent: ASTElement | undefined;

                                                                                    property plain

                                                                                    plain?: boolean;

                                                                                      property pre

                                                                                      pre?: true;

                                                                                        property processed

                                                                                        processed?: true;

                                                                                          property props

                                                                                          props?: { name: string; value: string }[];

                                                                                            property ref

                                                                                            ref?: string;

                                                                                              property refInFor

                                                                                              refInFor?: boolean;

                                                                                                property scopedSlots

                                                                                                scopedSlots?: Record<string, ASTElement>;

                                                                                                  property slotName

                                                                                                  slotName?: string;

                                                                                                    property slotScope

                                                                                                    slotScope?: string;

                                                                                                      property slotTarget

                                                                                                      slotTarget?: string;

                                                                                                        property ssrOptimizability

                                                                                                        ssrOptimizability?: SSROptimizability;

                                                                                                          property static

                                                                                                          static?: boolean;

                                                                                                            property staticClass

                                                                                                            staticClass?: string;

                                                                                                              property staticInFor

                                                                                                              staticInFor?: boolean;

                                                                                                                property staticProcessed

                                                                                                                staticProcessed?: boolean;

                                                                                                                  property staticRoot

                                                                                                                  staticRoot?: boolean;

                                                                                                                    property staticStyle

                                                                                                                    staticStyle?: string;

                                                                                                                      property styleBinding

                                                                                                                      styleBinding?: string;

                                                                                                                        property tag

                                                                                                                        tag: string;

                                                                                                                          property text

                                                                                                                          text?: string;

                                                                                                                            property transition

                                                                                                                            transition?: string | true;

                                                                                                                              property transitionMode

                                                                                                                              transitionMode?: string | null;

                                                                                                                                property transitionOnAppear

                                                                                                                                transitionOnAppear?: boolean;

                                                                                                                                  property type

                                                                                                                                  type: 1;

                                                                                                                                    property wrapData

                                                                                                                                    wrapData?: (code: string) => string;

                                                                                                                                      property wrapListeners

                                                                                                                                      wrapListeners?: (code: string) => string;

                                                                                                                                        interface ASTElementHandler

                                                                                                                                        interface ASTElementHandler {}

                                                                                                                                          property modifiers

                                                                                                                                          modifiers: ASTModifiers | undefined;

                                                                                                                                            property params

                                                                                                                                            params?: any[];

                                                                                                                                              property value

                                                                                                                                              value: string;

                                                                                                                                                interface ASTElementHandlers

                                                                                                                                                interface ASTElementHandlers {}

                                                                                                                                                  index signature

                                                                                                                                                  [key: string]: ASTElementHandler | ASTElementHandler[];

                                                                                                                                                    interface ASTExpression

                                                                                                                                                    interface ASTExpression {}

                                                                                                                                                      property expression

                                                                                                                                                      expression: string;

                                                                                                                                                        property ssrOptimizability

                                                                                                                                                        ssrOptimizability?: SSROptimizability;

                                                                                                                                                          property static

                                                                                                                                                          static?: boolean;

                                                                                                                                                            property text

                                                                                                                                                            text: string;

                                                                                                                                                              property tokens

                                                                                                                                                              tokens: (string | Record<string, any>)[];

                                                                                                                                                                property type

                                                                                                                                                                type: 2;

                                                                                                                                                                  interface ASTIfCondition

                                                                                                                                                                  interface ASTIfCondition {}

                                                                                                                                                                    property block

                                                                                                                                                                    block: ASTElement;

                                                                                                                                                                      property exp

                                                                                                                                                                      exp: string | undefined;

                                                                                                                                                                        interface ASTModifiers

                                                                                                                                                                        interface ASTModifiers {}

                                                                                                                                                                          index signature

                                                                                                                                                                          [key: string]: boolean;

                                                                                                                                                                            interface ASTText

                                                                                                                                                                            interface ASTText {}

                                                                                                                                                                              property isComment

                                                                                                                                                                              isComment?: boolean;

                                                                                                                                                                                property ssrOptimizability

                                                                                                                                                                                ssrOptimizability?: SSROptimizability;

                                                                                                                                                                                  property static

                                                                                                                                                                                  static?: boolean;

                                                                                                                                                                                    property text

                                                                                                                                                                                    text: string;

                                                                                                                                                                                      property type

                                                                                                                                                                                      type: 3;

                                                                                                                                                                                        interface CompiledResult

                                                                                                                                                                                        interface CompiledResult<ErrorType> {}

                                                                                                                                                                                          property ast

                                                                                                                                                                                          ast: ASTElement | undefined;

                                                                                                                                                                                            property errors

                                                                                                                                                                                            errors: ErrorType[];

                                                                                                                                                                                              property render

                                                                                                                                                                                              render: string;

                                                                                                                                                                                                property staticRenderFns

                                                                                                                                                                                                staticRenderFns: string[];

                                                                                                                                                                                                  property tips

                                                                                                                                                                                                  tips: ErrorType[];

                                                                                                                                                                                                    interface CompiledResultFunctions

                                                                                                                                                                                                    interface CompiledResultFunctions {}

                                                                                                                                                                                                      property render

                                                                                                                                                                                                      render: () => VNode;

                                                                                                                                                                                                        property staticRenderFns

                                                                                                                                                                                                        staticRenderFns: (() => VNode)[];

                                                                                                                                                                                                          interface CompilerOptions

                                                                                                                                                                                                          interface CompilerOptions {}

                                                                                                                                                                                                            property directives

                                                                                                                                                                                                            directives?: Record<string, DirectiveFunction>;

                                                                                                                                                                                                              property modules

                                                                                                                                                                                                              modules?: ModuleOptions[];

                                                                                                                                                                                                                property outputSourceRange

                                                                                                                                                                                                                outputSourceRange?: any;

                                                                                                                                                                                                                  property preserveWhitespace

                                                                                                                                                                                                                  preserveWhitespace?: boolean;

                                                                                                                                                                                                                    property whitespace

                                                                                                                                                                                                                    whitespace?: 'preserve' | 'condense';

                                                                                                                                                                                                                      interface CompilerOptionsWithSourceRange

                                                                                                                                                                                                                      interface CompilerOptionsWithSourceRange extends CompilerOptions {}

                                                                                                                                                                                                                        property outputSourceRange

                                                                                                                                                                                                                        outputSourceRange: true;

                                                                                                                                                                                                                          interface ErrorWithRange

                                                                                                                                                                                                                          interface ErrorWithRange {}

                                                                                                                                                                                                                            property end

                                                                                                                                                                                                                            end: number;

                                                                                                                                                                                                                              property msg

                                                                                                                                                                                                                              msg: string;

                                                                                                                                                                                                                                property start

                                                                                                                                                                                                                                start: number;

                                                                                                                                                                                                                                  interface ModuleOptions

                                                                                                                                                                                                                                  interface ModuleOptions {}

                                                                                                                                                                                                                                    property genData

                                                                                                                                                                                                                                    genData: (el: ASTElement) => string;

                                                                                                                                                                                                                                      property postTransformNode

                                                                                                                                                                                                                                      postTransformNode: (el: ASTElement) => void;

                                                                                                                                                                                                                                        property preTransformNode

                                                                                                                                                                                                                                        preTransformNode: (el: ASTElement) => ASTElement | undefined;

                                                                                                                                                                                                                                          property staticKeys

                                                                                                                                                                                                                                          staticKeys?: string[];

                                                                                                                                                                                                                                            property transformCode

                                                                                                                                                                                                                                            transformCode?: (el: ASTElement, code: string) => string;

                                                                                                                                                                                                                                              property transformNode

                                                                                                                                                                                                                                              transformNode: (el: ASTElement) => ASTElement | undefined;

                                                                                                                                                                                                                                                interface SFCBlock

                                                                                                                                                                                                                                                interface SFCBlock {}

                                                                                                                                                                                                                                                  property attrs

                                                                                                                                                                                                                                                  attrs: Record<string, string>;

                                                                                                                                                                                                                                                    property content

                                                                                                                                                                                                                                                    content: string;

                                                                                                                                                                                                                                                      property end

                                                                                                                                                                                                                                                      end?: number;

                                                                                                                                                                                                                                                        property lang

                                                                                                                                                                                                                                                        lang?: string;

                                                                                                                                                                                                                                                          property module

                                                                                                                                                                                                                                                          module?: string | boolean;

                                                                                                                                                                                                                                                            property scoped

                                                                                                                                                                                                                                                            scoped?: boolean;

                                                                                                                                                                                                                                                              property src

                                                                                                                                                                                                                                                              src?: string;

                                                                                                                                                                                                                                                                property start

                                                                                                                                                                                                                                                                start?: number;

                                                                                                                                                                                                                                                                  property type

                                                                                                                                                                                                                                                                  type: string;

                                                                                                                                                                                                                                                                    interface SFCDescriptor

                                                                                                                                                                                                                                                                    interface SFCDescriptor {}

                                                                                                                                                                                                                                                                      property customBlocks

                                                                                                                                                                                                                                                                      customBlocks: SFCBlock[];

                                                                                                                                                                                                                                                                        property script

                                                                                                                                                                                                                                                                        script: SFCBlock | undefined;

                                                                                                                                                                                                                                                                          property styles

                                                                                                                                                                                                                                                                          styles: SFCBlock[];

                                                                                                                                                                                                                                                                            property template

                                                                                                                                                                                                                                                                            template: SFCBlock | undefined;

                                                                                                                                                                                                                                                                              interface SFCParserOptions

                                                                                                                                                                                                                                                                              interface SFCParserOptions {}

                                                                                                                                                                                                                                                                                property deindent

                                                                                                                                                                                                                                                                                deindent?: boolean;

                                                                                                                                                                                                                                                                                  property pad

                                                                                                                                                                                                                                                                                  pad?: true | 'line' | 'space';

                                                                                                                                                                                                                                                                                    Type Aliases

                                                                                                                                                                                                                                                                                    type ASTNode

                                                                                                                                                                                                                                                                                    type ASTNode = ASTElement | ASTText | ASTExpression;

                                                                                                                                                                                                                                                                                      type DirectiveFunction

                                                                                                                                                                                                                                                                                      type DirectiveFunction = (node: ASTElement, directiveMeta: ASTDirective) => void;

                                                                                                                                                                                                                                                                                        type SSROptimizability

                                                                                                                                                                                                                                                                                        type SSROptimizability = 0 | 1 | 2 | 3 | 4;
                                                                                                                                                                                                                                                                                        • - 0: FALSE - whole sub tree un-optimizable - 1: FULL - whole sub tree optimizable - 2: SELF - self optimizable but has some un-optimizable children - 3: CHILDREN - self un-optimizable but have fully optimizable children - 4: PARTIAL - self un-optimizable with some un-optimizable children

                                                                                                                                                                                                                                                                                        Package Files (1)

                                                                                                                                                                                                                                                                                        Dependencies (2)

                                                                                                                                                                                                                                                                                        Dev Dependencies (1)

                                                                                                                                                                                                                                                                                        Peer Dependencies (0)

                                                                                                                                                                                                                                                                                        No peer dependencies.

                                                                                                                                                                                                                                                                                        Badge

                                                                                                                                                                                                                                                                                        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                                                                                        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/vue-template-compiler.

                                                                                                                                                                                                                                                                                        • Markdown
                                                                                                                                                                                                                                                                                          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/vue-template-compiler)
                                                                                                                                                                                                                                                                                        • HTML
                                                                                                                                                                                                                                                                                          <a href="https://www.jsdocs.io/package/vue-template-compiler"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>