Velocity Templates - New Line

后端 未结 6 1179
醉话见心
醉话见心 2021-02-13 04:07

I\'ve been working with Apache\'s Velocity engine and a custom template.
The thing is, that I haven\'t been able to generate a String with the corresponding line breaks. I t

6条回答
  •  后悔当初
    2021-02-13 04:46

    I needed a new line for generating javascript. Well, I didn't need it of course, but it made reading the generated code easier while developing. In this case, I just set a variable so that the Velocity was easier to read. This is all you need:

    Velocity Code:

    #set( $newline="
    ")
    #set( $jsCode = "var bling='blang';{$newline}var bark='bite';{$newline}" )
    
    

    Result:

    
    

提交回复
热议问题