Tree.

apply(source, target)

Copies all key and values from a map-based source tree to a map-based target tree.

If a key exists in both trees, and the values in both trees are subtrees, then the subtrees will be merged recursively. Otherwise, the value from the source tree will overwrite the value in the target tree. This operation leaves alone any keys in the target tree that aren’t mentioned in the source tree.

See also Tree.applyChanges, which compares the two trees and applies only the changes.

Example #

A build folder contains a tiny set of files:

$ ori build
about:
  index.html: About page
index.html: Home page

An Origami file contains a tree of changes to be applied:

// changes.ori
{
  about: {
    index.html: "About page 2"
  }
}

After the Tree.apply command, the build folder now reflects the changes:

$ ori Tree.apply changes.ori, build
$ ori build
about:
  index.html: About page 2
index.html: Home page