文件最后提交记录最后更新时间
Oops: Commit the missing root_gen.go to the vg-for example Fix: adds the root_gen.go file that was missed in initial commit to the repo. It also corrects a minor typo in the local .gitignore. 1 年前
Add the vg-for example Added an example that shows how loop using vg-for The example shows how to: * Use a for i loop * use a key value loop * use the vugu shortcut form of a key value loop * show how to sort a map so the loop order is consistent. This uses the maps, slices and iter packages * Show the use of a range over iterator loop style, using an iterator. 1 年前
Add the vg-for example Added an example that shows how loop using vg-for The example shows how to: * Use a for i loop * use a key value loop * use the vugu shortcut form of a key value loop * show how to sort a map so the loop order is consistent. This uses the maps, slices and iter packages * Show the use of a range over iterator loop style, using an iterator. 1 年前
Add the vg-for example Added an example that shows how loop using vg-for The example shows how to: * Use a for i loop * use a key value loop * use the vugu shortcut form of a key value loop * show how to sort a map so the loop order is consistent. This uses the maps, slices and iter packages * Show the use of a range over iterator loop style, using an iterator. 1 年前
Add the vg-for example Added an example that shows how loop using vg-for The example shows how to: * Use a for i loop * use a key value loop * use the vugu shortcut form of a key value loop * show how to sort a map so the loop order is consistent. This uses the maps, slices and iter packages * Show the use of a range over iterator loop style, using an iterator. 1 年前
Add the vg-for example Added an example that shows how loop using vg-for The example shows how to: * Use a for i loop * use a key value loop * use the vugu shortcut form of a key value loop * show how to sort a map so the loop order is consistent. This uses the maps, slices and iter packages * Show the use of a range over iterator loop style, using an iterator. 1 年前
Add the vg-for example Added an example that shows how loop using vg-for The example shows how to: * Use a for i loop * use a key value loop * use the vugu shortcut form of a key value loop * show how to sort a map so the loop order is consistent. This uses the maps, slices and iter packages * Show the use of a range over iterator loop style, using an iterator. 1 年前
Add the vg-for example Added an example that shows how loop using vg-for The example shows how to: * Use a for i loop * use a key value loop * use the vugu shortcut form of a key value loop * show how to sort a map so the loop order is consistent. This uses the maps, slices and iter packages * Show the use of a range over iterator loop style, using an iterator. 1 年前
Bug Fix: Update the vg-for example after the noshadow option was removed Updating the vg-for example after the noshadow vg-for option has been removed reveals a serious bug. Previously the `root.vugu` file contained this: <!-- This example uses the explicit form of the vg-for --> <!-- This time the methods c.DaysInWeekIthSorted uses the new iter, sllice and maps package internally --> <li vg-for='index, value := range c.DaysInWeekIterator()'> <div vg-content='fmt.Sprintf("The day of the week at index %d is %s", index, c.DayOfWeek(index))'></div> </li> This vg-for statement should have failed to compile. But it did not. It should have failed with an unused valriable "value" in the `root_gen.go` file. This compilation failure is correct - the variable "value" declared in the loop declaration is not used in the body of the loop. Following the removal of the `noshadow` option this test code then (correctly) failed with the unused variable error. The test code has now been corrected to remove any reference to the unused variable, "value". 1 年前
Update the generated code for examples after the noshadow changes Update the generated code used inthe examples, following theremoval of the noshadow option. The impacted examples are: dom-events embed-and-translate fetch-and-display html-form vg-for vg-if 1 年前
Update the generated code for examples after the noshadow changes Update the generated code used inthe examples, following theremoval of the noshadow option. The impacted examples are: dom-events embed-and-translate fetch-and-display html-form vg-for vg-if 1 年前
Readme.md

vg-for Conditional example

A very simple example that primarily demonstrates how the vg-for attribute on an HTML element.

Building the example

This build instructions are based on using mage as the built tool. If you require a different built tool please use the generic method of building in the Readme at the root of the examples package.

Building the example is easy.

You will need docker and mage preinstalled before you begin.

First you must clone the vugu repository:

git clone https://github.com/vugu/vugu

Now cd into the cloned repository directory

cd vugu

The vugu project uses mage as its preferred build tool, so building the example is simply

mage SingleExample github.com/vugu/vugu/examples/vg-for

If that works then in the shell you will see:

Local nginx container started.
Connect to http://localhost:8889/<example-test-directory-name>
e,g. http://localhost:8889/fetch-and-display
To stop the local nginx container please run:
	mage StopLocalNginxForExamples

The mage SingleExample github.com/vugu/vugu/examples/vg-for command will build the example in question, as well as all of the vugu tools. This ensures that the example is always built with the latest version of the vugu tools.

Running the example

To run the example, we follow the instructions in the shell.

Open a browser at http://localhost:8889/vg-for/

And the example will load and run.

Changing the example

Changing the example is also easy.

The general principle is that you should update the root.go or root.vugu files as needed and then rerun mage SingleExample github.com/vugu/vugu/examples/vg-for, then refresh the browser so that it loads new wasm example binary.

So for example update the Root.ListLength() method from:

// Return the current list length
func (c *Root) ListLength() int {
	return len(c.list)
}

to

// Return the current list length
func (c *Root) ListLength() int {
    fmt.Printf("Current list length: %d\n", len(c.list))
	return len(c.list)
}

Then run

mage SingleExample github.com/vugu/vugu/examples/vg-for

Again browse to http://localhost:8889/vg-for/ and refresh the browser.

You should now see the list length being displayed in the JavaScript console when the list is rendered.