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 功能 #12

Closed
subchen opened this issue Nov 21, 2013 · 0 comments
Closed

增加自定义 Tag 功能 #12

subchen opened this issue Nov 21, 2013 · 0 comments
Assignees
Labels
Milestone

Comments

@subchen
Copy link
Owner

subchen commented Nov 21, 2013

用法:

先用 Java 定义一个 Tag:比如 cache

public static void cache(JetTagContext ctx, String name) {
    String value = CacheManager.get(name);
    if (value == null) {
        value = ctx.getBodyContent();
        CacheManager.set(name, value);
    }
    ctx.getWriter().write(value);
}

然后在模板中使用:

#tag cache("1-1-1")
    ......
    ${header()} ${header()} ${header()}
    ... 其他内容...
#end
@ghost ghost assigned subchen Nov 21, 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