... | ... | @@ -13,4 +13,92 @@ Au moment de la compilation, tous les fichiers de structure/ et de templates/ so |
|
|
|
|
|
# Reformuler un élement de structure et de gabarit
|
|
|
|
|
|
La manière la plus simple de modifier un élément de structure sans toucher au Javascript ni avoir besoin de recompiler est de proposer les reformulations directement dans la page web dans laquelle est hébergée le client. Cela se fait en insérant des balises <script> avec |
|
|
\ No newline at end of file |
|
|
La manière la plus simple de modifier un élément de structure sans toucher au Javascript ni avoir besoin de recompiler est de proposer les reformulations directement dans la page web dans laquelle est hébergée le client. Cela se fait en insérant des balises <script> avec un attribut type à la valeur "text/x-scrutari-structure" pour un élément de structure et "text/x-scrutari-template" pour un gabarit et un attribut data-name indiquant le nom du fichier à remplacer (en omettant le .html).
|
|
|
|
|
|
L'exemple suivant simplifie la zone d'affichage des statistiques en affichant que le nombre de résultats (en supprimant le nombre total et le nombre après filtre), pour la bibliothèque Bootstrap 3 (voir [l'original](https://framagit.org/Scrutari/scrutarijs/blob/master/src/html/bootstrap3/structure/area-stats.html)) :
|
|
|
|
|
|
```html
|
|
|
<script data-name="area-stats" type="text/x-scrutari-structure">
|
|
|
<div data-scrutari-area="stats" class="scrutari-area-Stats">
|
|
|
<div class="row">
|
|
|
<div class="col-xs-12">
|
|
|
{{stats-result}}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</script>
|
|
|
```
|
|
|
|
|
|
L'exemple suivant est une reformulation du gabarit d'affichage du résultat d'une fiche pour que la valeur de l'attribut sct:authors soit afffiché à côté de l'année (voir [l'original](https://framagit.org/Scrutari/scrutarijs/blob/master/src/html/_default/templates/fiche.html)), c'est le gabarit le plus complexe :
|
|
|
|
|
|
```html
|
|
|
<script data-name="fiche" type="text/x-scrutari-template">
|
|
|
{{!-- --}}
|
|
|
<div class='scrutari-fiche-Block' data-scrutari-block='fiche_{{:codefiche}}'>
|
|
|
{{if icon}}
|
|
|
<div class='scrutari-fiche-Icon'><img alt='' src='{{:icon}}'/></div>
|
|
|
{{/if}}
|
|
|
<p class='scrutari-fiche-Titre'>
|
|
|
<a href='{{:href}}'
|
|
|
class='scrutari-fiche-Link'
|
|
|
data-scrutari-link='fiche_{{:codefiche}}'
|
|
|
{{if target}} target='{{:target}}'{{/if}}>
|
|
|
{{if mtitre}}
|
|
|
{{:~scrutari_mark(mtitre)}}
|
|
|
{{else}}
|
|
|
{{:href}}
|
|
|
{{/if}}
|
|
|
</a>
|
|
|
</p>
|
|
|
{{if msoustitre}}
|
|
|
<p class='scrutari-fiche-Soustitre'>
|
|
|
{{:~scrutari_mark(msoustitre)}}
|
|
|
</p>
|
|
|
{{/if}}
|
|
|
|
|
|
{{if annee || hasAttribute("sct:authors")}}
|
|
|
<p class='scrutari-fiche-Annee'>
|
|
|
{{if hasAttribute("sct:authors")}}
|
|
|
{{for mattrMap["sct:authors"] ~len=mattrMap["sct:authors"].length}}
|
|
|
{{:~scrutari_mark(#data)}}{{if #index != (~len -1)}}, {{/if}}
|
|
|
{{/for}}
|
|
|
{{/if}}
|
|
|
{{if annee && hasAttribute("sct:authors")}}
|
|
|
–
|
|
|
{{/if}}
|
|
|
{{:annee}}
|
|
|
</p>
|
|
|
{{/if}}
|
|
|
|
|
|
{{if mcomplementArray}}
|
|
|
{{for mcomplementArray}}
|
|
|
<p class='scrutari-fiche-Complement'>
|
|
|
<span class="scrutari-label-Complement">
|
|
|
{{>title}}
|
|
|
{{>~scrutari_loc("_ colon")}}
|
|
|
</span>
|
|
|
{{:~scrutari_mark(mcomp)}}
|
|
|
</p>
|
|
|
{{/for}}
|
|
|
{{/if}}
|
|
|
|
|
|
{{for secondaryAttributeArray tmpl="scrutari-fiche_attributes" /}}
|
|
|
|
|
|
{{if motcleArray}}
|
|
|
<p class="scrutari-fiche-Motcle">
|
|
|
<span class="scrutari-label-Motcle">
|
|
|
{{if motcleArray.length == 1}}
|
|
|
{{>~scrutari_loc("_ fiche_motscles_one")}}
|
|
|
{{else}}
|
|
|
{{>~scrutari_loc("_ fiche_motscles_many")}}
|
|
|
{{/if}}
|
|
|
</span>
|
|
|
{{for motcleArray ~len=motcleArray.length}}
|
|
|
{{for mlibelleArray}}{{if #index > 0}}/{{/if}}{{:~scrutari_mark(mlib)}}{{/for}}{{if #index != (~len -1)}}, {{/if}}
|
|
|
{{/for}}
|
|
|
</p>
|
|
|
{{/if}}
|
|
|
</div>
|
|
|
|
|
|
</script>
|
|
|
``` |
|
|
\ No newline at end of file |