Home | History | Annotate | Download | only in docs

Lines Matching full:template

20   <title>Android IDE Template Format</title>
37 <h1>Android IDE Template Format</h1>
55 <p>Although these templates were originally introduced in the <a href="http://developer.android.com/tools/sdk/eclipse-adt.html">ADT Plugin</a> for Eclipse, the template format is designed for use by any IDE or command-line tool.</p>
57 <p>Templates are customizable. Each template exposes several options (called parameters) that allow developers to customize the generated code. The most common workflow for <em>using</em> a template is as follows:</p>
60 <li>Choose a template.</li>
61 <li>Populate template options (parameters).</li>
69 <p>By convention, any file in the template directory structure that is to be processed by FreeMarker should have the <code>.ftl</code> file extension. So if one of your source files is <code>MyActivity.java</code>, and it contains FreeMarker instructions, it should be named something like <code>MyActivity.java.ftl</code>.</p>
96 <p>In this example excerpt from the <code>BlankActivity</code> template:</p>
99 <li>The expression <code>${activityClass}</code> is bound to the value of the 'Activity Class' template parameter.</li>
100 <li>The expression <code>${activityToLayout(activityClass)}</code> uses the <code>activityToLayout</code> method built into the template engine to convert an activity class such as <code>MyFooActivity</code> to <code>activity_my_foo</code>.</li>
101 <li>The <code>isLauncher</code> boolean variable and <code>parentActivityClass</code> string variables are bound to the values of the 'Launcher Activity' and 'Hierarchical Parent' template parameter, respectively.</li>
110 <p>A template is a directory containing a number of XML and FreeMarker files. The only two mandatory files are <code>template.xml</code> and <code>recipe.xml.ftl</code>. Template source files (PNG files, templated Java and XML files, etc.) belong in a <code>root/</code> subdirectory. An example directory structure for a template is below:</p>
114 <li><a href="#toc_templatexml">template.xml</a> <span class="dim">&mdash; Metadata (description, parameters, etc.)</span></li>
117 <li>template.png <span class="dim">&mdash; Default template thumbnail</span></li>
138 <h3>template.xml</h3>
140 <p>Each template directory must contain a <code>template.xml</code> file. This XML file contains metadata about the template, including the name, description, category and user-visible parameters that the IDE will present as options to the user. The XML file also indicates the name of the <a href="#toc_recipexmlftl">recipe XML file</a> (which gets processed by FreeMarker), and the <a href="#toc_globalsxmlftl">global variables XML file</a> if there are global variables besides the template parameter values that should be visible to all FreeMarker-processed files (<code>.ftl</code> files).</p>
142 <p>An example <code>template.xml</code> is shown below.</p>
145 &lt;!-- A template for a blank activity. Use template format
147 &lt;template
209 the template. --&gt;
211 &lt;/template&gt;
214 <p>Below is a listing of supported tags in <code>template.xml</code>.</p>
216 <h4 class="includetoc">&lt;template&gt;</h4>
218 <p>The template root element.</p>
222 <dd>The template format version that this template adheres to. Should be <code>4</code>.</dd>
225 <dd>Optional. The version of this template (which you can increment when updating the template), as an integer.</dd>
228 <dd>The template's display name.</dd>
231 <dd>The template's description.</dd>
234 <dd>Optional. The minimum API level required for this template. The IDE will ensure that the target project has a <code>minSdkVersion</code> no lower than this value before instantiating the template.</dd>
237 <dd>Optional. The minimum build target (expressed as an API level) required for this template. The IDE will ensure that the target project is targeting an API level greater than or equal to this value before instantiating the template. This ensures that the template can safely use newer APIs (optionally guarded by runtime API level checks) without introducing compile-time errors into the target project.</dd>
243 <p>This tag is deprecated for use in <code>template.xml</code>. Use <a href="#toc_recipe_dependency"><code>&lt;dependency&gt;</code></a> in <code>recipe.xml.ftl</code> instead.</p>
245 <p>Indicates that the template requires that a given library be present in the target project. If not present, the IDE will add the dependency to the project.</p>
255 <dd>The minimum revision of the library required by this template.</dd>
262 <p>The template type. This element is optional.</p>
266 <dd>The template type. Should be one of the following values: <ul>
276 <p>Defines a user-customizable template parameter.</p>
283 <dd>The display name of the template parameter.</dd>
328 <dd>Optional. The minimum API level required if this option is chosen. The IDE will ensure that the target project has a <code>minSdkVersion</code> no lower than this value before instantiating the template.</dd>
336 template. <code>&lt;thumb&gt;</code> elements should be contained inside a <code>&lt;thumbs&gt;</code> element. The text contents of this element represent the path to the thumbnail. If this element has any attributes, they will be treated as selectors for parameter values. For example, if there are two thumbnails:</p>
340 &lt;thumb&gt;template.png&lt;/thumb&gt;
345 <p>The template 'preview' thumbnail will show <code>template_tabs.png</code> if the value of the <code>navType</code> template parameter is <code>tabs</code> and <code>template.png</code> otherwise.</p>
349 <p>States that the template would like the Asset Studio icon creation tool of the given type to run, and save the output icons with the given name.</p>
361 <p>The optional globals XML file contains global variable definitions, for use in all FreeMarker processing jobs for this template.</p>
378 <p>The recipe XML file contains the individual instructions that should be executed when generating code from this template. For example, you can copy certain files or directories (the copy instruction), optionally running the source files through FreeMarker (the instantiate instruction), and ask the IDE to open a file after the code has been generated (the open instruction).</p>
380 <p class="note"><strong>Note:</strong> The name of the recipe file is up to you, and is defined in <code>template.xml</code>. By convention, however, it's best to call it <code>recipe.xml.ftl</code>.</p>
393 [template-directory]/root/ to [output-directory],
458 <p>Indicates that the template requires that a given library be present in the target project. If not present, the IDE will add the dependency to the project.</p>
492 <p>The actual template files (resources, Java sources, Android Manifest changes) should be placed in the <code>root/</code> directory, in a directory structure that roughly resembles what the output directory structure should look like.</p>
499 <h2>Built-in Template Functions</h2>
649 <h2>Built-in Template Parameters</h2>
651 <p>Several parameters are available to FreeMarker expressions and files beyond <a href="#toc_parameter">those defined by the template</a>. These are listed below.</p>
659 <p>Will be the application package (i.e. the package name declared in the app manifest) if the target package for this template is not the application package. Otherwise, this parameter will be empty.</p>
663 <p>A boolean indicating whether or not this template is being instantiated as part of a New Project flow.</p>
709 <h2>Notes for Template Authors</h2>