+++ /dev/null
-<templates>
- <t t-name="trim-content-both" t-trim="both">
- ok
- </t>
- <t t-name="trim-content-before" t-trim="left"> ok </t>
- <t t-name="trim-content-after" t-trim="right"> ok </t>
- <t t-name="trim-content-unknown" t-trim="stuff"> ok </t>
-
- <t t-name="trim-children-text" t-trim="inner">o k</t>
- <t t-name="trim-children-elements" t-trim="inner">
- <foo/>
- <bar/>
- </t>
- <t t-name="trim-mixed-children" t-trim="inner">
- [ <foo/> ]
- </t>
- <t t-name='trim-children-left' t-trim="left inner"> <foo/> <bar/> </t>
- <t t-name='trim-children-right' t-trim="right inner"> <foo/> <bar/> </t>
-</templates>
"Call with t-import (calls in current context)");
});
- module("Trim", {
- setup: function () {
- QWeb.add_template('qweb-test-trim.xml');
- },
- teardown: function () {
- QWeb.templates = [];
- QWeb.tag = {};
- QWeb.att = {};
- }
- });
- test('Trim content', function () {
- equals(QWeb.render('trim-content-both', {}), 'ok',
- "Trims before and after content");
- equals(QWeb.render('trim-content-before', {}), 'ok ',
- "Trims before content");
- equals(QWeb.render('trim-content-after', {}), ' ok',
- "Trims after content");
- raises(function () {QWeb.render('trim-content-unknown', {});},
- "Trims with an unknown mode");
- });
- test('Trim content *and* children', function () {
- equals(QWeb.render('trim-children-text', {}), 'o k',
- "Trims text children");
- equals(QWeb.render('trim-children-elements', {}), '<foo/><bar/>',
- "Full trim");
- equals(QWeb.render('trim-mixed-children', {}), '[<foo/>]',
- "Trims mixed content of text and elements");
- equals(QWeb.render('trim-children-left', {}), '<foo/><bar/> ',
- "Trims children and left of content");
- equals(QWeb.render('trim-children-right', {}), ' <foo/><bar/>',
- "Trims children and right of content");
- });
-
module("Foreach", {
setup: function () {
QWeb.add_template('qweb-test-foreach.xml');