Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 14 for AddParseTree (0.22 sec)

  1. src/html/template/template_test.go

    		t.Errorf("ParseGlob: %v\nwanted error about already having Executed", err)
    	}
    	if _, err := c.root.AddParseTree("t1", c.root.Tree); err == nil || !strings.Contains(err.Error(), "Execute") {
    		t.Errorf("AddParseTree: %v\nwanted error about already having Executed", err)
    	}
    }
    
    func TestNumbers(t *testing.T) {
    	c := newTestCase(t)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Sep 06 15:48:16 UTC 2022
    - 6.2K bytes
    - Viewed (0)
  2. src/text/template/template.go

    		rightDelim: t.rightDelim,
    	}
    }
    
    // AddParseTree associates the argument parse tree with the template t, giving
    // it the specified name. If the template has not been defined, this tree becomes
    // its definition. If it has been defined and already has that name, the existing
    // definition is replaced; otherwise a new template is created, defined, and returned.
    func (t *Template) AddParseTree(name string, tree *parse.Tree) (*Template, error) {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Feb 26 20:57:51 UTC 2024
    - 7.2K bytes
    - Viewed (0)
  3. src/cmd/vendor/github.com/google/pprof/internal/driver/webhtml.go

    	}
    
    	// Define a named template with specified contents.
    	def := func(name, contents string) {
    		sub := template.New(name)
    		template.Must(sub.Parse(contents))
    		template.Must(templates.AddParseTree(name, sub.Tree))
    	}
    
    	// Embedded files.
    	def("css", loadCSS("html/common.css"))
    	def("header", loadFile("html/header.html"))
    	def("graph", loadFile("html/graph.html"))
    	def("graph_css", loadCSS("html/graph.css"))
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri May 31 19:48:28 UTC 2024
    - 2.6K bytes
    - Viewed (0)
  4. src/text/template/multi_test.go

    	if err != nil {
    		t.Fatal(err)
    	}
    	// Add a new parse tree.
    	tree, err := parse.Parse("cloneText3", cloneText3, "", "", nil, builtins())
    	if err != nil {
    		t.Fatal(err)
    	}
    	added, err := root.AddParseTree("c", tree["c"])
    	if err != nil {
    		t.Fatal(err)
    	}
    	// Execute.
    	var b strings.Builder
    	err = added.ExecuteTemplate(&b, "a", 0)
    	if err != nil {
    		t.Fatal(err)
    	}
    	if b.String() != "broot" {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Sep 08 10:48:29 UTC 2022
    - 11.7K bytes
    - Viewed (0)
  5. src/html/template/template.go

    			tmpl = t.new(name)
    		}
    		tmpl.text = v
    		tmpl.Tree = v.Tree
    	}
    	return t, nil
    }
    
    // AddParseTree creates a new template with the name and parse tree
    // and associates it with t.
    //
    // It returns an error if t or any associated template has already been executed.
    func (t *Template) AddParseTree(name string, tree *parse.Tree) (*Template, error) {
    	if err := t.checkCanParse(); err != nil {
    		return nil, err
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Mar 21 21:00:46 UTC 2024
    - 17K bytes
    - Viewed (0)
  6. src/html/template/multi_test.go

    	tmpl := New("master")
    	tree, err := parse.Parse("master", master, "", "", nil)
    	if err != nil {
    		t.Fatalf("unexpected parse err: %v", err)
    	}
    	masterTree := tree["master"]
    	tmpl.AddParseTree("master", masterTree) // used to panic
    }
    
    func TestRedefinition(t *testing.T) {
    	var tmpl *Template
    	var err error
    	if tmpl, err = New("tmpl1").Parse(`{{define "test"}}foo{{end}}`); err != nil {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Sep 06 15:48:16 UTC 2022
    - 8K bytes
    - Viewed (0)
  7. src/html/template/clone_test.go

    	tree, err := parse.Parse("t", `{{define "b"}}<a href="{{end}}`, "", "", nil, nil)
    	if err != nil {
    		t.Fatal(err)
    	}
    	added := Must(root.AddParseTree("b", tree["b"]))
    	b := new(strings.Builder)
    	err = added.ExecuteTemplate(b, "a", "1>0")
    	if err != nil {
    		t.Fatal(err)
    	}
    	if got, want := b.String(), ` 1&gt;0 <a href=" 1%3e0 "></a>`; got != want {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Sep 06 15:48:16 UTC 2022
    - 8K bytes
    - Viewed (0)
  8. src/html/template/escape.go

    			insertedIdents[normalizeEscFn(idNode.Ident)] = true
    		}
    	}
    	for _, name := range s {
    		if !insertedIdents[normalizeEscFn(name)] {
    			// When two templates share an underlying parse tree via the use of
    			// AddParseTree and one template is executed after the other, this check
    			// ensures that escapers that were already inserted into the pipeline on
    			// the first escaping pass do not get inserted again.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Oct 02 15:18:39 UTC 2023
    - 32.4K bytes
    - Viewed (0)
  9. src/text/template/doc.go

    necessary to have a template addressable from multiple associations, the
    template definition must be parsed multiple times to create distinct *Template
    values, or must be copied with [Template.Clone] or [Template.AddParseTree].
    
    Parse may be called multiple times to assemble the various associated templates;
    see [ParseFiles], [ParseGlob], [Template.ParseFiles] and [Template.ParseGlob]
    for simple ways to parse related templates stored in files.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Sat Feb 24 21:59:12 UTC 2024
    - 17.9K bytes
    - Viewed (0)
  10. src/html/template/escape_test.go

    		data     = `<baz>`
    		want     = `&lt;baz&gt;`
    	)
    	// Templates "foo" and "bar" both alias the same underlying parse tree.
    	tpl := Must(New("foo").Parse(tmplText))
    	if _, err := tpl.AddParseTree("bar", tpl.Tree); err != nil {
    		t.Fatalf("AddParseTree error: %v", err)
    	}
    	var b1, b2 strings.Builder
    	if err := tpl.ExecuteTemplate(&b1, "foo", data); err != nil {
    		t.Fatalf(`ExecuteTemplate failed for "foo": %v`, err)
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Oct 16 03:29:27 UTC 2023
    - 56.2K bytes
    - Viewed (0)
Back to top