2
2
3
3
JavaScript | Templating | Stylesheets | Miscellaneous
4
4
--- | --- | --- | ---
5
- [ closure_js_library] | [ closure_js_template_library ] | [ closure_css_library] | [ closure_js_proto_library]
6
- [ closure_js_binary] | [ closure_java_template_library ] | [ closure_css_binary] | [ phantomjs_test]
7
- [ closure_js_test] | [ closure_py_template_library ] | | [ closure_proto_library] \( Experimental\)
5
+ [ closure_js_library] | [ closure_css_library] | [ closure_js_proto_library]
6
+ [ closure_js_binary] | [ closure_css_binary] | [ phantomjs_test]
7
+ [ closure_js_test] | [ closure_proto_library] \( Experimental\)
8
8
| | | | [ closure_grpc_web_library] \( Experimental\)
9
9
10
10
## Overview
@@ -27,9 +27,7 @@ play games. It enforces a type system that can be stricter than Java. From a
27
27
stylistic perspective, Closure is [ verbose] like Java; there's no cryptic
28
28
symbols or implicit behavior; the code says exactly what it's doing. This sets
29
29
Closure apart from traditional JavaScript development, where terseness was
30
- favored over readability, because minifiers weren't very good. Furthermore, the
31
- Closure Library and Templates help you follow security best practices which will
32
- keep your users safe.
30
+ favored over readability, because minifiers weren't very good.
33
31
34
32
### What's Included
35
33
@@ -41,7 +39,6 @@ Closure Rules bundles the following tools and makes them "just work."
41
39
transpiles [ ECMASCRIPT6] to minified ES3 JavaScript that can run in any
42
40
browser.
43
41
- [ Closure Library] : Google's core JavaScript libraries.
44
- - [ Closure Templates] : Type-safe HTML templating system that compiles to both
45
42
JavaScript and Java. This is one of the most secure templating systems
46
43
available. It's where Google has put the most thought into preventing things
47
44
like XSS attacks. It also supports i18n and l10n.
@@ -136,7 +133,6 @@ Please see the test directories within this project for concrete examples of usa
136
133
137
134
- [ //closure/testing/test] ( https://github.com/bazelbuild/rules_closure/tree/master/closure/testing/test )
138
135
- [ //closure/compiler/test] ( https://github.com/bazelbuild/rules_closure/tree/master/closure/compiler/test )
139
- - [ //closure/templates/test] ( https://github.com/bazelbuild/rules_closure/tree/master/closure/templates/test )
140
136
- [ //closure/stylesheets/test] ( https://github.com/bazelbuild/rules_closure/tree/master/closure/stylesheets/test )
141
137
- [ //closure/protobuf/test] ( https://github.com/bazelbuild/rules_closure/tree/master/closure/protobuf/test )
142
138
@@ -190,8 +186,7 @@ This rule can be referenced as though it were the following:
190
186
list that image here, so it ends up in the webserver runfiles.
191
187
192
188
- ** deps:** (List of [ labels] ; optional) Direct [ dependency] list. These can
193
- point to [ closure_js_library] , [ closure_js_template_library] ,
194
- [ closure_css_library] and [ closure_js_proto_library] rules.
189
+ point to [ closure_js_library] , [ closure_css_library] and [ closure_js_proto_library] rules.
195
190
196
191
- ** exports:** (List of [ labels] ; optional) Listing dependencies here will cause
197
192
them to become * direct* dependencies in parent rules. This functions similarly
@@ -284,14 +279,14 @@ This rule can be referenced as though it were the following:
284
279
285
280
- ** deps:** (List of [ labels] ; required) Direct dependency list. This attribute
286
281
has the same meaning as it does in [ closure_js_library] . These can point to
287
- [ closure_js_library] and [ closure_js_template_library ] rules.
282
+ [ closure_js_library] rules.
288
283
289
284
- ** css:** (Label; optional) CSS class renaming target, which must point to a
290
285
[ closure_css_binary] rule. This causes the CSS name mapping file generated by
291
286
the CSS compiler to be included in the compiled JavaScript. This tells
292
287
Closure Compiler how to minify CSS class names.
293
288
294
- This attribute is required if any of JavaScript or template sources depend on
289
+ This attribute is required if any of JavaScript sources depend on
295
290
a [ closure_css_library] . This rule will check that all the referenced CSS
296
291
libraries are present in the CSS binary.
297
292
@@ -499,158 +494,6 @@ This rule can be referenced as though it were the following:
499
494
to report the result to the ` harness ` .
500
495
501
496
502
- ## closure\_ js\_ template\_ library
503
-
504
- ``` starlark
505
- load(" @io_bazel_rules_closure//closure:defs.bzl" , " closure_js_template_library" )
506
- closure_js_template_library(name, srcs, data, deps, globals , plugin_modules,
507
- should_generate_js_doc,
508
- should_generate_soy_msg_defs,
509
- bidi_global_dir,
510
- soy_msgs_are_external,
511
- defs)
512
- ```
513
-
514
- Compiles Closure templates to JavaScript source files.
515
-
516
- This rule is necessary in order to render Closure templates from within
517
- JavaScript code.
518
-
519
- This rule pulls in a transitive dependency on the Closure Library.
520
-
521
- The documentation on using Closure Templates can be found
522
- [ here] [ Closure Templates ] .
523
-
524
- For additional help on using some of these attributes, please see the output of
525
- the following:
526
-
527
- bazel run @com_google_template_soy//:SoyToJsSrcCompiler -- --help
528
-
529
- #### Implicit Output Targets
530
-
531
- - * src* .js: A separate JavaScript source file is generated for each file listed
532
- under ` srcs ` . The filename will be the same as the template with a ` .js `
533
- suffix. For example ` foo.soy ` would become ` foo.soy.js ` .
534
-
535
- #### Rule Polymorphism
536
-
537
- This rule can be referenced as though it were the following:
538
-
539
- - [ filegroup] : ` srcs ` will be the generated JS output files and ` data ` will
540
- contain all transitive JS sources and data.
541
-
542
- - [ closure_js_library] : ` srcs ` will be the generated JS output files, ` data `
543
- will contain the transitive data, ` deps ` will contain necessary libraries, and
544
- ` no_closure_library ` will be ` False ` .
545
-
546
- ### Arguments
547
-
548
- - ** name:** ([ Name] ; required) A unique name for this rule.
549
-
550
- - ** srcs:** (List of [ labels] ; required) A list of ` .soy ` source files that
551
- represent this library.
552
-
553
- - ** data:** (List of [ labels] ; optional) Runfiles directly referenced by Soy
554
- sources in this rule. For example, if the template has an ` <img src=foo.png> `
555
- tag, then the data attribute of its rule should be set to ` ["foo.png"] ` so the
556
- image is available in the web server runfiles.
557
-
558
- - ** deps:** (List of [ labels] ; optional) List of [ closure_js_library] ,
559
- [ closure_js_template_library] and [ closure_js_proto_library] targets which
560
- define symbols referenced by the template.
561
-
562
- - ** globals:** (List of [ labels] ; optional) List of text files containing symbol
563
- definitions that are only considered at compile-time. For example, this file
564
- might look as follows:
565
-
566
- com.foo.bar.Debug.PRODUCTION = 0
567
- com.foo.bar.Debug.DEBUG = 1
568
- com.foo.bar.Debug.RAW = 2
569
-
570
- - ** plugin_modules:** (List of [ labels] ; optional; default is ` [] ` ) Passed along
571
- verbatim to the SoyToJsSrcCompiler above.
572
-
573
- - ** should_generate_js_doc:** (Boolean; optional; default is ` True ` ) Passed
574
- along verbatim to the SoyToJsSrcCompiler above.
575
-
576
- - ** should_generate_soy_msg_defs:** (Boolean; optional; default is ` False ` )
577
- Passed along verbatim to the SoyToJsSrcCompiler above.
578
-
579
- - ** bidi_global_dir:** (Integer; optional; default is ` 1 ` )
580
- Passed along verbatim to the SoyToJsSrcCompiler above.
581
- Valid values are 1 (LTR) or -1 (RTL).
582
-
583
- - ** soy_msgs_are_external:** (Boolean; optional; default is ` False ` ) Passed
584
- along verbatim to the SoyToJsSrcCompiler above.
585
-
586
- - ** defs:** (List of strings; optional) Passed along verbatim to the
587
- SoyToJsSrcCompiler above.
588
-
589
- ## closure\_ java\_ template\_ library
590
-
591
- ``` starlark
592
- load(" @io_bazel_rules_closure//closure:defs.bzl" , " closure_java_template_library" )
593
- closure_java_template_library(name, srcs, data, deps, java_package)
594
- ```
595
-
596
- Compiles Closure templates to Java source files.
597
-
598
- This rule is necessary in order to serve Closure templates from a Java backend.
599
-
600
- Unlike [ closure_js_template_library] , globals are not specified by this rule.
601
- They get added at runtime by your Java code when serving templates.
602
-
603
- This rule pulls in a transitive dependency on Guava, Guice, and ICU4J.
604
-
605
- The documentation on using Closure Templates can be found
606
- [ here] [ Closure Templates ] .
607
-
608
- For additional help on using some of these attributes, please see the output of
609
- the following:
610
-
611
- bazel run @com_google_template_soy//:SoyParseInfoGenerator -- --help
612
-
613
- #### Implicit Output Targets
614
-
615
- - SrcSoyInfo.java: A separate Java source file is generated for each file
616
- listed under ` srcs ` . The filename will be the same as the template, converted
617
- to upper camel case, with a ` SoyInfo.java ` suffix. For example ` foo_bar.soy `
618
- would become ` FooBarSoyInfo.java ` .
619
-
620
- #### Rule Polymorphism
621
-
622
- This rule can be referenced as though it were the following:
623
-
624
- - [ filegroup] : ` srcs ` will be the compiled jar file and ` data ` will contain all
625
- transitive data.
626
-
627
- - [ java_library] : ` srcs ` will be the generated Java source files, and ` data `
628
- will contain the transitive data.
629
-
630
- ### Arguments
631
-
632
- - ** name:** ([ Name] ; required) A unique name for this rule.
633
-
634
- - ** srcs:** (List of [ labels] ; required) A list of ` .soy ` source files that
635
- represent this library.
636
-
637
- - ** data:** (List of [ labels] ; optional) Runfiles directly referenced by Soy
638
- sources in this rule. For example, if the template has an ` <img src=foo.png> `
639
- tag, then the data attribute of its rule should be set to ` ["foo.png"] ` so the
640
- image is available in the web server runfiles.
641
-
642
- - ** deps:** (List of [ labels] ; optional) Soy files to parse but not to generate
643
- outputs for.
644
-
645
- - ** java_package:** (List of [ labels] ; required) The package for the Java files
646
- that are generated, e.g. ` "com.foo.soy" ` .
647
-
648
-
649
- ## closure\_ py\_ template\_ library
650
-
651
- TODO
652
-
653
-
654
497
## closure\_ css\_ library
655
498
656
499
``` starlark
@@ -665,8 +508,7 @@ This rule does not compile your stylesheets; it is used in conjunction with
665
508
666
509
This rule should be referenced by any [ closure_js_library] rule whose sources
667
510
contain a ` goog.getCssName('foo') ` call if ` foo ` is a CSS class name defined by
668
- this rule. The same concept applies to [ closure_js_template_library] rules that
669
- contain ` {css('foo')} ` expressions.
511
+ this rule.
670
512
671
513
#### Rule Polymorphism
672
514
@@ -783,10 +625,6 @@ This rule can be referenced as though it were the following:
783
625
target, so the build system can verify (at compile time) that your CSS and
784
626
JS binaries are both being compiled in a harmonious way.
785
627
786
- You'll also need update your templates to say ` {css('foo-bar')} ` in place of
787
- class names. The [ closure_js_template_library] must also depend on the
788
- appropriate CSS library.
789
-
790
628
- ** debug:** (Boolean; optional; default is ` False ` ) Enables debug mode, which
791
629
causes the compiled stylesheet to be pretty printed. If ` renaming = True ` then
792
630
class names will be renamed, but still readable to humans.
@@ -844,9 +682,6 @@ Defines a set of Protocol Buffer files.
844
682
845
683
- * name* .js: A generated protocol buffer JavaScript library.
846
684
847
- - * name* .descriptor: A protoc FileDescriptorsSet representation of the .proto
848
- files.
849
-
850
685
#### Rule Polymorphism
851
686
852
687
This rule can be referenced as though it were the following:
@@ -909,7 +744,6 @@ This rule can be referenced as though it were the following:
909
744
[ Closure Compiler ] : https://developers.google.com/closure/compiler/
910
745
[ Closure Library ] : https://developers.google.com/closure/library/
911
746
[ Closure Stylesheets ] : https://github.com/google/closure-stylesheets
912
- [ Closure Templates ] : https://developers.google.com/closure/templates/
913
747
[ Closure Tools ] : https://developers.google.com/closure/
914
748
[ Closure coding conventions ] : https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/ClosureCodingConvention.java
915
749
[ ECMASCRIPT6 ] : http://es6-features.org/
@@ -928,14 +762,11 @@ This rule can be referenced as though it were the following:
928
762
[ closure_css_binary ] : #closure_css_binary
929
763
[ closure_css_library ] : #closure_css_library
930
764
[ closure_grpc_web_library ] : https://github.com/grpc/grpc-web/blob/9b7b2d5411c486aa646ba2491cfd894d5352775b/bazel/closure_grpc_web_library.bzl#L149
931
- [ closure_java_template_library ] : #closure_java_template_library
932
765
[ closure_js_binary ] : #closure_js_binary
933
766
[ closure_js_library ] : #closure_js_library
934
767
[ closure_js_proto_library ] : #closure_js_proto_library
935
- [ closure_js_template_library ] : #closure_js_template_library
936
768
[ closure_js_test ] : #closure_js_test
937
769
[ closure_proto_library ] : #closure_proto_library
938
- [ closure_py_template_library ] : #closure_py_template_library
939
770
[ coffeescript ] : http://coffeescript.org/
940
771
[ compiler-issue ] : https://github.com/google/closure-compiler/issues/new
941
772
[ css-sourcemap ] : https://developer.chrome.com/devtools/docs/css-preprocessors
0 commit comments