summaryrefslogtreecommitdiffstats
path: root/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/utils/ParserFactory/JinjaXML.ts
blob: 7a80424330131604c71639705e04fdaa5aa444ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Parser } from './Parser';

export class JinjaXMLParser implements Parser {
    getVariables(fileContent: string): string[] {
        const variables = [];
        if (fileContent.includes('>[')) {
            const xmlSplit = fileContent.split('>[');
            for (const val of xmlSplit) {
                const res = val.substring(0, val.indexOf(']</'));
                if (res && res.length > 0) {
                    variables.push(res);
                }

            }
        }
        return variables;
    }

}

/*

<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:junos="http://xml.juniper.net/junos/17.4R1/junos">
<system xmlns="http://yang.juniper.net/junos-qfx/conf/system">
<host-name operation="delete" />
<host-name operation="create">[hostname]</host-name>
</system>
</configuration>

*/