Support alternate ng2-translate attribute in DirectiveParser. Add more tests
This commit is contained in:
parent
ff93233f6b
commit
e5f937d7f6
@ -22,7 +22,7 @@ export class DirectiveParser extends AbstractTemplateParser implements ParserInt
|
||||
.addBack()
|
||||
.each((i: number, element: CheerioElement) => {
|
||||
const $element = $(element);
|
||||
const attr = $element.attr('translate');
|
||||
const attr = $element.attr('translate') || $element.attr('ng2-translate');
|
||||
|
||||
if (attr) {
|
||||
results.push(attr);
|
||||
|
@ -80,10 +80,26 @@ describe('DirectiveParser', () => {
|
||||
expect(messages).to.deep.equal(['Hello World']);
|
||||
});
|
||||
|
||||
it('should extract when using alternate translate attribute', () => {
|
||||
const contents = '<div ng2-translate>Hello World<div>';
|
||||
|
||||
|
||||
|
||||
|
||||
it('should extract contents when no ng2-translate attribute value is provided', () => {
|
||||
const contents = '<div ng2-translate>Hello World</div>';
|
||||
const messages = parser.process(templateFilename, contents);
|
||||
expect(messages).to.deep.equal(['Hello World']);
|
||||
});
|
||||
|
||||
it('should extract ng2-translate attribute if provided', () => {
|
||||
const contents = '<div ng2-translate="KEY">Hello World<div>';
|
||||
const messages = parser.process(templateFilename, contents);
|
||||
expect(messages).to.deep.equal(['KEY']);
|
||||
});
|
||||
|
||||
it('should extract bound ng2-translate attribute as key if provided', () => {
|
||||
const contents = `<div [ng2-translate]="'KEY'">Hello World<div>`;
|
||||
const messages = parser.process(templateFilename, contents);
|
||||
expect(messages).to.deep.equal(['KEY']);
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user