<ws:file> | Standard JET2 Workspace Tags
--- | ---

file

Create or write an Eclipse workspace file. If the file does not exist, the tag attempts to create it and any containing folders. An error occurs if the file does not exist and cannot be created.

Note that the actual creation of the workspace file is deferred until the JET2Context passed to the executing template has the 'commit' method calls. If the template is part of a JET2 transformation, this occurs once all templates have executed.

If the 'file' tag is contained directly or indirectly by a 'folder' or 'project' tag AND the 'path' attribute on this tag is relative (does not start with a '/'), then the 'path' attribute is treated as relative to the containing 'folder' or 'project'.

An absolute 'path' (one starting with '/') is treated as a workspace relative path. That is, the first component after the slash is interpreted as the name of an Eclipse Project, and subsequence segments are treated as folder names, with the last segment being interpreted as the file name.

When executing, this tag will cause the implicit creation of any folders containing the folder to be created. It will not implicitly create a containing workspace project.

Tag Summary
required | <ws:file path="value" template="value"/>
full tag | <ws:file path="value" template="value" encoding="value" replace="value" derived="value"/>

Required Attributes
path | A relative path (no initial '/') or an absolute path.
template | A project-relative path of a JET template to execute. The template provides the file's contents.

Optional Attributes
encoding | The character encoding of the file. If omitted, then the Eclipse workspace determines the encoding. If provided, then the encoding is changed to the specified value. A value of '#default' restores the encoding of the file to the workspace determined default.
replace | A boolean ('true' or 'false') value. If 'true', the tag will overwrite an existing file, otherwise it will not. If omitted, a value of 'true' is assumed.
derived | A boolean value ('true' or 'false') determining the value of the workspace 'derived' attribute for the file. If omitted, a value of 'false' is assumed.

Example
| <%-- write a file about.html to myProject after evaluating template about.html.jet--%> <ws:file path="myProject/about.html" template="templates/about.html.jet"/> <%-- alternative way of doing the about--%> <ws:project name="myProject"> <ws:file path="about.html" template="templates/about.html.jet"/> ... other ws:file tags writing to the same project ... </ws:project>