Skip to content

Commit

Permalink
replay-tests: fasttags and gtfasttags on classpath example
Browse files Browse the repository at this point in the history
  • Loading branch information
xabolcs committed Feb 13, 2025
1 parent b15e858 commit 80ddb6e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package hello.fasttags;

import groovy.lang.Closure;
import play.templates.ExecutableTemplate;
import play.templates.FastTags;
import java.io.PrintWriter;
import java.util.Map;

@FastTags.Namespace("core")
public class HelloFromCore extends FastTags {

public static void _hello (Map<?, ?> args, Closure<String> body, PrintWriter out, ExecutableTemplate template, int fromLine) {
String name = args.containsKey("name") ? args.get("name").toString() : "";
if (name.isEmpty()) {
throw new play.exceptions.TagInternalException("name attribute cannot be empty for " + Thread.currentThread().getStackTrace()[1].getMethodName().substring(1) + " tag");
}

out.println("Hello, " + name + "!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package hello.fasttags;

import play.template2.GTContentRenderer;
import play.template2.GTFastTag;
import play.template2.GTJavaBase;
import java.util.Map;

@GTFastTag.TagNamespace("coreGT")
public class HelloFromCoreGT extends GTFastTag {
public static void tag_hello (GTJavaBase template, Map<String, Object> args, GTContentRenderer content) {
String name = args.containsKey("name") ? args.get("name").toString() : "";
if (name.isEmpty()) {
throw new play.exceptions.TagInternalException("name attribute cannot be empty for " + Thread.currentThread().getStackTrace()[1].getMethodName().substring(4) + " tag");
}

template.out.append("Hello, ").append(name).append("!");
}
}
3 changes: 2 additions & 1 deletion replay-tests/multi-module-app/core/app/views/hello.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#{include './meta.html'/}
</head>
<body>
<h1>Hello, ${who}!</h1>
<h1 id="fasttag_hello_core">#{core.hello name: who /}</h1>
<h1 id="gt_hello_core">#{coreGT.hello name: who /}</h1>
#{include './core.html'/}

</body>
Expand Down

0 comments on commit 80ddb6e

Please sign in to comment.