brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geomacy <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #392: [WIP] $brooklyn:self().template("freemark...
Date Wed, 26 Oct 2016 10:47:00 GMT
Github user geomacy commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/392#discussion_r85093511
  
    --- Diff: camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/parse/DslParser.java
---
    @@ -52,7 +53,29 @@ public Object next() {
             if (index >= expression.length())
                 throw new IllegalStateException("Unexpected end of expression to parse, looking
for content since position "+start);
             
    -        if (expression.charAt(index)=='"') {
    +        String multilineTemplatePrefix = "$brooklyn:template";
    +        if (expression.regionMatches(index, multilineTemplatePrefix, 0, multilineTemplatePrefix.length()))
{
    +            // skip to next line
    +            char c;
    +            do {
    +                c = expression.charAt(index);
    +                index++;
    +            } while(c != '\n' && index<expression.length());
    +            if (index < expression.length()) {
    +                int stringStart = index;
    +                index = expression.length();
    +                return new QuotedString('"' + JavaStringEscapes.escapeJavaString(expression.substring(stringStart,
index)) + '"');
    --- End diff --
    
    Need to skip trailing newline/whitespace on the expression: I tried updating the test
to add further text:
    
    ```java
        protected Entity entityWithMultilineTemplatedString() throws Exception {
            return setupAndCheckTestEntityInBasicYamlWith(
                    "  id: x",
                    "  brooklyn.config:",
                    "    test.sourceName: hello world",
                    "    test.confName: |",
                    "      $brooklyn:template",
                    "      ${config['test.sourceName']}",
                    "    test.other: something else");
        }
    ```
    
    and it breaks with 
    ```
    java.lang.AssertionError: expected [hello world] but found [hello world
    ]
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message