Browse Source

Polyfill Uint8Array support

https://github.com/robertkrimen/otto/issues/89
Andy Hochhaus 3 years ago
parent
commit
f3900a1039
6 changed files with 1061 additions and 4 deletions
  1. 2 0
      BUILD
  2. 7 0
      defs.bzl
  3. 1 1
      test/BUILD
  4. 1 1
      test/soyotto_test.go
  5. 2 2
      test/test.soy
  6. 1048 0
      typedarray.js

+ 2 - 0
BUILD

@@ -16,6 +16,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_prefix", "go_library")
 
 go_prefix("github.com/socialworkout/soyotto")
 
+exports_files(["typedarray.js"])
+
 go_library(
     name = "go_default_library",
     srcs = glob(["*.go"]),

+ 7 - 0
defs.bzl

@@ -99,6 +99,13 @@ def soyotto_idom_template(
       deps = [":" + name + "_noidom_js_lib"],
   )
 
+  native.genrule(
+      name = name + "_soyotto",
+      srcs = [str(Label("//:typedarray.js")), ":" + name + "_noidom_bin.js"],
+      outs = [name + "_soyotto.js"],
+      cmd = "cat $(SRCS) > $@",
+  )
+
 def go_proto_library(
     name,
     srcs,

+ 1 - 1
test/BUILD

@@ -56,7 +56,7 @@ go_test(
         ":protoex",
     ],
     data = [
-        ":test_tpl_noidom_bin",
+        ":test_tpl_soyotto",
     ],
 )
 

+ 1 - 1
test/soyotto_test.go

@@ -31,7 +31,7 @@ func load() error {
 	if loaded {
 		return nil
 	}
-	if err := soyotto.LoadFile("test_tpl_noidom_bin.js"); err != nil {
+	if err := soyotto.LoadFile("test_tpl_soyotto.js"); err != nil {
 		return err
 	}
 	loaded = true

+ 2 - 2
test/test.soy

@@ -25,6 +25,6 @@
  * Protobuf example
  */
 {template .protoHello}
-  {@param test: test.protoex.Test}
-  <p>Hello {$test.name}!</p>
+  {@param pb: test.protoex.Test}
+  <p>Hello {$pb.name}!</p>
 {/template}

File diff suppressed because it is too large
+ 1048 - 0
typedarray.js