-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement a Bazel extension for compiling Closure Template files to J…
…avaScript.
- Loading branch information
Showing
9 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
bazel/ | ||
bazel-bin/ | ||
bazel* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
def soy_library( | ||
name, | ||
srcs, | ||
should_provide_require_soy_namespaces = True, | ||
visibility=None): | ||
|
||
additional_compiler_args = [] | ||
if should_provide_require_soy_namespaces: | ||
additional_compiler_args += [ | ||
'--shouldProvideRequireSoyNamespaces'] | ||
|
||
native.genrule( | ||
name = name, | ||
srcs = srcs, | ||
outs = [src + '.js' for src in srcs], | ||
cmd = '$(JAVA) -jar $(location //tools:soy_js_compiler) ' + | ||
'--srcs $(SRCS) ' + | ||
'--outputPathFormat $(@D)/{INPUT_FILE_NAME}.js ' + | ||
'--shouldGenerateJsdoc ' + | ||
'--isUsingIjData ' + | ||
' '.join(additional_compiler_args), | ||
message = 'Compiling templates to JavaScript', | ||
tools = ["//tools:soy_js_compiler"], | ||
visibility = visibility, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
load("/closure_templates", "soy_library") | ||
|
||
soy_library( | ||
name = "demo_soy", | ||
srcs = glob(["*.soy"]), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{namespace demo} | ||
|
||
/** Example template. */ | ||
{template .template} | ||
{/template} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
filegroup( | ||
name = "soy_js_compiler", | ||
srcs = ["SoyToJsSrcCompiler.jar"], | ||
visibility = ["//visibility:public"], | ||
) |
Binary file not shown.