# Multiple/Nested Templates

**URL:** <https://discuss.blues.com/t/multiple-nested-templates/576>\
**Category:** Notecard API\
**Created:** [December 28, 2021, 6:48pm UTC](https://discuss.blues.com/t/multiple-nested-templates/576 "2021-12-28T18:48:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![richf](https://avatars.discourse-cdn.com/v4/letter/r/74df32/32.png) [@richf](https://discuss.blues.com/u/richf)\
**Post date:** [December 28, 2021, 6:48pm UTC](https://discuss.blues.com/t/multiple-nested-templates/576/1 "2021-12-28T18:48:24Z")

</div>

Will the notecard handle multiple templates (with each a unique ‘file’ name)? - so that a template can be chosen at ‘run-time’ based on the message being output.

Also, can templates be nested … like an ‘array’ of structures a template could contain an array of templates?

regards, Rich …

---

<div class="post-metadata">

**Author:** ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)\
**Post date:** [December 29, 2021, 1:54pm UTC](https://discuss.blues.com/t/multiple-nested-templates/576/2 "2021-12-29T13:54:05Z")

</div>

Hi @richf,

Yes, you can utilize multiple templates on a single Notecard (and you’re correct that the template to be used is specified by the `file` parameter in a `note.add` request).

Templates cannot be nested. I’m curious to know your use case though!

Thanks,  
Rob

---

<div class="post-metadata">

**Author:** ![richf](https://avatars.discourse-cdn.com/v4/letter/r/74df32/32.png) [@richf](https://discuss.blues.com/u/richf)\
**Post date:** [December 29, 2021, 2:47pm UTC](https://discuss.blues.com/t/multiple-nested-templates/576/3 "2021-12-29T14:47:57Z")

</div>

Hi Rob,

We monitor a “variable” number of devices from 0 to 16 – with each device having the same return data fields. So, if 3 devices are currently ‘on-line’, the message sent to the Notecard from the HOST, will have a ‘pre-amble’ and an array of 3 ‘structures’ (one for each device) – the number of ‘on-line’ devices can change in real-time …

An alternative to ‘nested’ structures would be to define 17 templates … one for each of up to 16 devices and a ‘special’ case of no devices. We would then choose the appropriate template based on the number of devices ‘on-line’.

regards, Rich …
