Skip to content

Commit 5288d7f

Browse files
committed
support filters in partials (close #735)
1 parent f9f500c commit 5288d7f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/directives/partial.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ module.exports = {
3939
var partial = this.vm.$options.partials[id]
4040
_.assertAsset(partial, 'partial', id)
4141
if (partial) {
42+
var filters = this.filters && this.filters.read
43+
if (filters) {
44+
partial = _.applyFilters(partial, filters, this.vm)
45+
}
4246
this.compile(templateParser.parse(partial, true))
4347
}
4448
}

test/unit/specs/directives/partial_spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,25 @@ if (_.inBrowser) {
111111
})
112112
})
113113

114+
it('partial with filters', function () {
115+
var vm = new Vue({
116+
el: el,
117+
template: '<div>{{>test | replace}}</div>',
118+
partials: {
119+
test: '{{a}}'
120+
},
121+
data: {
122+
a: 'A',
123+
b: 'B'
124+
},
125+
filters: {
126+
replace: function () {
127+
return '{{b}}'
128+
}
129+
}
130+
})
131+
expect(el.innerHTML).toBe('<div>' + wrap('B') + '</div>')
132+
})
133+
114134
})
115135
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy