From c11a706bbf2a5c139ed8188950ec5dcf2eaa2de6 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 17 Apr 2016 19:03:29 -0400 Subject: [PATCH] v-text --- src/compiler/codegen/directives/index.js | 2 ++ src/compiler/codegen/directives/text.js | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 src/compiler/codegen/directives/text.js diff --git a/src/compiler/codegen/directives/index.js b/src/compiler/codegen/directives/index.js index b3091e31..bb226177 100644 --- a/src/compiler/codegen/directives/index.js +++ b/src/compiler/codegen/directives/index.js @@ -1,5 +1,6 @@ import { model } from './model' import { show } from './show' +import { text } from './text' import { html } from './html' import { ref } from './ref' export { genHandlers } from './on' @@ -7,6 +8,7 @@ export { genHandlers } from './on' export const directives = { model, show, + text, html, ref, cloak: function () {} // noop diff --git a/src/compiler/codegen/directives/text.js b/src/compiler/codegen/directives/text.js new file mode 100644 index 00000000..39690db2 --- /dev/null +++ b/src/compiler/codegen/directives/text.js @@ -0,0 +1,8 @@ +export function text (el, dir) { + if (!dir.value) return + if (!el.props) el.props = [] + el.props.push({ + name: 'textContent', + value: `__toString__(${dir.value})` + }) +}