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

增加 #tag block(name) 默认实现,配合 #include 实现多个内容块的 layout #35

Closed
subchen opened this issue Dec 4, 2013 · 1 comment
Assignees
Labels
Milestone

Comments

@subchen
Copy link
Owner

subchen commented Dec 4, 2013

main.jetx

#tag block("bodyContent1")
    BODY 1111
#end
#tag block("bodyContent2")
    BODY 2222
#end
#include ("layout.jetx")

layout.jetx

This is a header.
<div>
    ${bodyContent1}
</div>
<div>
    ${bodyContent2}
</div>
This is a footer.

输出结果:

This is a header.
<div>
    BODY 1111
</div>
<div>
    BODY 2222
</div>
This is a footer.
@ghost ghost assigned subchen Dec 4, 2013
@subchen
Copy link
Owner Author

subchen commented Dec 4, 2013

/**
 * 将一个 Block 的内容保存到一个 Context 变量中。
 * 
 * @param ctx Tag 上下文对象
 * @param name 保存到 JetContext 的变量名
 */
public static void block(JetTagContext ctx, String name) {
    String bodyContent = ctx.getBodyContent();
    ctx.getContext().put(name, bodyContent);
}

@subchen subchen closed this as completed in a0e6dbc Dec 4, 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

1 participant