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

#if #else #end 语句后面貌似丢了一个换行 #25

Closed
yingzhuo opened this issue Dec 3, 2013 · 2 comments
Closed

#if #else #end 语句后面貌似丢了一个换行 #25

yingzhuo opened this issue Dec 3, 2013 · 2 comments
Assignees
Labels
Milestone

Comments

@yingzhuo
Copy link

yingzhuo commented Dec 3, 2013

java code:

JetContext context = new JetContext();
context.put("flag", Boolean.FALSE);

jetx:

========
IF语句:#if(flag)flag为true#else()flag为false#end
========

output

========
IF语句:flag为false========

version

1.1.0
@ghost ghost assigned subchen Dec 3, 2013
@subchen
Copy link
Owner

subchen commented Dec 3, 2013

默认开启 trim.directive.line,会删除指令行两边的空白,所以 #end 后面的 \r\n 会删掉了。

一般是这么写的

#if(flag)
flag为true
#else()
flag为false
#end

考虑到如果 #if/#else/#end 内联的情况 (同一行), 可以优化一下,保留一个 \r\n

不过内联的情况,一般建议使用三元表达式: ${flag ? "flag为true" : "flag为false"}

@yingzhuo
Copy link
Author

yingzhuo commented Dec 3, 2013

谢谢指点,很喜欢你的这个开源项目。 已经申请加入贵开发群,希望通过验证。 本人qq23007067

@subchen subchen closed this as completed in cc61156 Dec 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants