Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.1 produces empty text #12

Closed
staeff777 opened this issue Feb 16, 2017 · 3 comments
Closed

3.0.1 produces empty text #12

staeff777 opened this issue Feb 16, 2017 · 3 comments

Comments

@staeff777
Copy link

I tried to migrate to 3.0.1 , however I have now problems with the rendering.
Following Example produces an empty String:

scalaVersion := "2.11.8"

import org.clapper.scalasti.{STGroupFile, STGroupString}
...

  val templateString =
    """
      |foo(firstName, lastName) ::= <<
      |This is a test template. It spans multiple lines, and it interpolates
      |a first name (<firstName>) and a last name (<lastName>).
    """.stripMargin

  val tgroup = STGroupString(templateString)
  tgroup.instanceOf("foo").map { template =>
    template set ("firstName", "john")
    template set ("lasttName", "doe")
    println(template.render())
    println(template.render.get)
  }
    .recover {
      case e: Exception => // handle error
    }
@staeff777
Copy link
Author

Sorry, I should have read the last comment better. Strangely the text is still empty.

val templateString =
    """
      |foo(firstName, lastName) ::= <<
      |This is a test template. It spans multiple lines, and it interpolates
      |a first name (<firstName>) and a last name (<lastName>).
    """.stripMargin

  val tgroup = STGroupString(templateString)
  tgroup.instanceOf("foo").map { template =>
   println( template.add ("firstName", "john").add("lasttName", "doe").render())


  }
    .recover {
      case e: Exception => // handle error
    }

@staeff777
Copy link
Author

Ok, I found it. I did not print the exception.
The problem was, that the template string has no function closing signs >>.
So the 3.0.1. is working properly.

val templateString =
    """
      |foo(firstName, lastName) ::= <<
      |This is a test template. It spans multiple lines, and it interpolates
      |a first name (<firstName>) and a last name (<lastName>).>>
    """.stripMargin

The source is the Simple Examples section.

@bmc
Copy link
Owner

bmc commented Feb 16, 2017

Yeah, that would do it.

At least 3.0.x now returns the exceptions. Previously, the only way to get them was by registering a listener with StringTemplate.

@bmc bmc closed this as completed Feb 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants