# Component Template Reference Guide

| <p>Template Editor Templates</p><p><strong>PDF, HTML, DOC</strong></p> | <p>Microsoft Templates</p><p><strong>DOCX, PPTX, XLSX</strong></p> | **PDF-Upload Component**                                                                                  |
| ---------------------------------------------------------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
| {{{{!Component Template Name}}}}                                       | \[{{{{!Component Template Name}}}}]                                | <p>{{{{!Component Template Name componentType="pdf-upload"}}}}<br><br><strong>OR</strong><br><br><br></p> |

## Component Query Model

Used to repeat a component once per SOQL record.

```
<!--{{!
<lineitemsSOQL>
  <component>
    Component Template Name
  </component>
  <soql>
    SELECT Id FROM Opportunity
  </soql>
</lineitemsSOQL>
}}-->
```

***

## Optimized Component Query Model (Single SOQL Execution)

```
<!--{{!
<lineitemsSOQL>
  <class>none</class>
  <soql>
    SELECT Id, Name, Field__c FROM Opportunity
  </soql>

  <component columnFields="true" mergeFieldPrefix="rec">
    Component Template Name
  </component>

  <column componentMergeField="true">Id</column>
  <column componentMergeField="true">Name</column>
  <column componentMergeField="true">Field__c</column>

</lineitemsSOQL>
}}-->
```

Inside the Component:

```
{{!rec.Name}}
{{!rec.Field__c}}
```

## Attributes

<table data-header-hidden data-full-width="true"><thead><tr><th width="368"></th><th></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Attribute</strong></td><td><strong>Explanation</strong></td><td></td><td><strong>Example</strong></td></tr><tr><td><code>{{{{!TemplateName}}}}</code></td><td>Merges a Component template at the insertion point.</td><td>1. Inherits parent record context<br>2. Executes once per placement<br>3. Supports nesting<br>4. Case-sensitive template name</td><td><p><strong>Opportunity Summary</strong></p><p><br><br>{{{{!Opportunity Pricing Component}}}}<br><br></p><p>Thank you for your business.</p></td></tr><tr><td><code>&#x3C;component></code></td><td>Used inside <code>&#x3C;lineitemsSOQL></code> to repeat a Component per query result</td><td>1. Executes once per returned record<br>2. Provides record-level context to the component<br>3. Supports nested components<br>4. Can be optimized using <code>columnFields="true"</code></td><td></td></tr><tr><td><code>&#x3C;column componentMergeField="true"></code></td><td>Passes queried fields into the component when using <code>columnFields="true"</code></td><td>1. Uses parent query results<br>2. Requires <code>&#x3C;column componentMergeField="true"></code><br>3. Requires <code>mergeFieldPrefix</code><br>4. Only one SOQL query executes</td><td><br>Opportunity Compact Block<br><br><br>OR<br><br>Name<br>StageName<br>Amount<br><br><strong>Component usage:</strong><br><br>{{!opp.Name}}<br>{{!opp.StageName}}<br>{{!opp.Amount}}</td></tr><tr><td><code>mergeFieldPrefix="prefixName"</code></td><td>Defines the namespace used inside the component when using <code>columnFields="true"</code></td><td>1. Required when <code>columnFields="true"</code> is used<br>2. All merge fields inside the component must use the prefix<br>3. Prefix is case-sensitive</td><td><strong>Parent</strong>:<br><br><code>&#x3C;br>&#x3C;component columnFields="true" mergeFieldPrefix="opp">&#x3C;br>&#x3C;br></code><br><br><strong>Component</strong>:<br><br><code>&#x3C;br>{{!opp.Name}}&#x3C;br>{{!opp.StageName}}&#x3C;br></code></td></tr><tr><td><code>componentType="pdf-upload"</code></td><td>Specifies that the merged template is a PDF-Upload template.</td><td>1. Used only for PDF-Upload templates<br>2. Can be applied in <code>{{{{! }}}}</code> syntax or <code>&#x3C;template></code> syntax<br>3. Ignored for non-PDF-Upload templates</td><td>{{{{!Master Service Agreement componentType="pdf-upload"}}}}<br><br><br><strong>Or:</strong><br><br></td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.sdocs.com/developer-hub/template-configuration-and-styling/component-template-reference-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
