Browse Source

allow registering custom compile-time directives

Evan You 10 years ago
parent
commit
3e39d7647d
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/compiler/index.js

+ 5 - 0
src/compiler/index.js

@@ -1,5 +1,6 @@
 import { parse } from './parser/index'
 import { generate } from './codegen/index'
+import { directives } from './codegen/directives/index'
 
 const cache1 = Object.create(null)
 const cache2 = Object.create(null)
@@ -10,3 +11,7 @@ export function compile (html, preserveWhitespace) {
   const hit = cache[html]
   return hit || (cache[html] = generate(parse(html, preserveWhitespace)))
 }
+
+export function registerDirective (name, fn) {
+  directives[name] = fn
+}