Uploaded image for project: 'Apache Freemarker'
  1. Apache Freemarker
  2. FREEMARKER-106

Unable to parse variable containing special char ${# with freemarker.template.Template.process(object,writer)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Information Provided
    • 2.3.23
    • None
    • engine
    • None

    Description

      Unable to parse variable containing ${# e.g ${#marker_files[@]} or ${#array[@]}

      Sample snippet:

      -----------------------------

      Configuration cfg = new Configuration(Configuration.VERSION_2_3_28);
      cfg.setLogTemplateExceptions(false);
      cfg.setClassForTemplateLoading(FtlExpressionEvaluator.class, "templates");
      cfg.setDefaultEncoding("UTF-8");
      cfg.setLocale(Locale.US);
      cfg.setTemplateExceptionHandler(TemplateExceptionHandler.IGNORE_HANDLER);
      cfg.setNumberFormat("0.######");

      Template t = new Template("freeMarkerTemplate", new StringReader(line), cfg);

       

      Error stack:

      freemarker.core.ParseException: Syntax error in template "freeMarkerTemplate" in line 1, column 13:
      Lexical error: encountered "m" (109), after "#".
      at freemarker.core.TokenMgrError.toParseException(TokenMgrError.java:260)
      at freemarker.template.Template.<init>(Template.java:269)
      at freemarker.template.Template.<init>(Template.java:203)
      at freemarker.template.Template.<init>(Template.java:182)
      at freemarker.template.Template.<init>(Template.java:125)

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            AmarG Amar Gurung
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: