Template usage/syntax

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Template usage/syntax

John Preimonas-2
Hi,
I am now delving into the realms of Tempting. So, can you please help me to understand the syntax for templates?

I am trying to put in a condition so that I get either a no results message or results from a query, e.g.

<table class="app:unions">
<thead>
                <td>Spouse </td>
                <td>Partner </td>
                <td>When </td>
                <td>Where </td>
                <td>Offspring </td>
</thead>
<tbody>
    <tr class="templates:if-parameter-unset?param=unions" >
        <td>No Marriage data available</td>
    </tr>
        <tr class="templates:each?from=unions&amp;to=union">
                <td class="app:print-maleCode"></td>
                <td class="app:print-femaleCode"></td>
                <td class="app:print-marriageDate"></td>
                <td class="app:print-marriagePlace"></td>
                <td class="app:print-offspring"></td>
        </tr>
</tbody>
   
</table>

where: app:unions =

declare
        %templates:wrap
        %templates:default("idCode", "BURTONJF")
function app:unions($node as node(), $model as map(*), $idCode as xs:string) as map(*) {
map { "unions" := collection('/db/apps/sandpit' || "/data/unions")/marriage[maleCode = $idCode or femaleCode = $idCode] }
};

Unfortunately, I get both the No Marriage message as well as the results of the Unions search. From my reading of the documentation, if “unions” is not set or empty that I would get the No Marriage message, and if there were results in “unions” that this template condition would not be activated.
What am I missing?

As a suggestion, perhaps you could provide some further examples in Templates documentation to make the usage and syntax a bit clearer (for us newbies to eXist)

Cheers,
John
------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: Template usage/syntax

Loren Cahlander
You can check out this video.


Sent from my iPad

On Jun 29, 2015, at 3:11 AM, John Preimonas <[hidden email]> wrote:

Hi,
I am now delving into the realms of Tempting. So, can you please help me to understand the syntax for templates?

I am trying to put in a condition so that I get either a no results message or results from a query, e.g.

<table class="app:unions">
<thead>
       <td>Spouse </td>
       <td>Partner </td>
       <td>When </td>
       <td>Where </td>
       <td>Offspring </td>
</thead>
<tbody>
   <tr class="templates:if-parameter-unset?param=unions" >
       <td>No Marriage data available</td>
   </tr>
   <tr class="templates:each?from=unions&amp;to=union">
       <td class="app:print-maleCode"></td>
       <td class="app:print-femaleCode"></td>
       <td class="app:print-marriageDate"></td>
       <td class="app:print-marriagePlace"></td>
       <td class="app:print-offspring"></td>
   </tr>
</tbody>

</table>

where: app:unions =

declare
   %templates:wrap
   %templates:default("idCode", "BURTONJF")
function app:unions($node as node(), $model as map(*), $idCode as xs:string) as map(*) {
map { "unions" := collection('/db/apps/sandpit' || "/data/unions")/marriage[maleCode = $idCode or femaleCode = $idCode] }
};

Unfortunately, I get both the No Marriage message as well as the results of the Unions search. From my reading of the documentation, if “unions” is not set or empty that I would get the No Marriage message, and if there were results in “unions” that this template condition would not be activated.
What am I missing?

As a suggestion, perhaps you could provide some further examples in Templates documentation to make the usage and syntax a bit clearer (for us newbies to eXist)

Cheers,
John
------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open

------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: Template usage/syntax

John Preimonas-2
Thanks Loren, it's a help. I will experiment a bit more to get a grip on it. 
Cheers, John 

Sent from my iPhone

On 29 Jun 2015, at 20:28, [hidden email] wrote:

You can check out this video.


Sent from my iPad

On Jun 29, 2015, at 3:11 AM, John Preimonas <[hidden email]> wrote:

Hi,
I am now delving into the realms of Tempting. So, can you please help me to understand the syntax for templates?

I am trying to put in a condition so that I get either a no results message or results from a query, e.g.

<table class="app:unions">
<thead>
       <td>Spouse </td>
       <td>Partner </td>
       <td>When </td>
       <td>Where </td>
       <td>Offspring </td>
</thead>
<tbody>
   <tr class="templates:if-parameter-unset?param=unions" >
       <td>No Marriage data available</td>
   </tr>
   <tr class="templates:each?from=unions&amp;to=union">
       <td class="app:print-maleCode"></td>
       <td class="app:print-femaleCode"></td>
       <td class="app:print-marriageDate"></td>
       <td class="app:print-marriagePlace"></td>
       <td class="app:print-offspring"></td>
   </tr>
</tbody>

</table>

where: app:unions =

declare
   %templates:wrap
   %templates:default("idCode", "BURTONJF")
function app:unions($node as node(), $model as map(*), $idCode as xs:string) as map(*) {
map { "unions" := collection('/db/apps/sandpit' || "/data/unions")/marriage[maleCode = $idCode or femaleCode = $idCode] }
};

Unfortunately, I get both the No Marriage message as well as the results of the Unions search. From my reading of the documentation, if “unions” is not set or empty that I would get the No Marriage message, and if there were results in “unions” that this template condition would not be activated.
What am I missing?

As a suggestion, perhaps you could provide some further examples in Templates documentation to make the usage and syntax a bit clearer (for us newbies to eXist)

Cheers,
John
------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open