Skip to content

Commit

Permalink
utilizando filtros para criar json em include
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus-vieira committed Apr 3, 2020
1 parent ed56d05 commit 977d0b0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
6 changes: 4 additions & 2 deletions _estabelecimentos/exemplo_email.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
nome: "Estabelecimento Com E-mail"
email: "[email protected]"
telefone: "5541988024599"
whatsapp: ""
endereco:
logradouro: "Rua Teste, 3157"
bairro: "Sítio Cercado"
cidade: "Curitiba"
uf: "PR"
categoria: [ "mercado", "padaria", "açougue" ]
categoria:
- mercado
- padaria
- açougue
---
7 changes: 5 additions & 2 deletions _estabelecimentos/exemplo_whatsapp.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
---
nome: "Estabelecimento Com Whattsapp"
email: ""
telefone: "5541988024599"
whatsapp: "5541988024599"
endereco:
logradouro: "Rua Teste, 3157"
bairro: "Sítio Cercado"
cidade: "Curitiba"
uf: "PR"
categoria: [ "ferragem", "hortifruti", "padaria", "açougue" ]
categoria:
- ferragem
- hortifruti
- padaria
- açougue
---
9 changes: 9 additions & 0 deletions _includes/estabelecimento.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": {{ include.id | jsonify }},
"nome": {{ include.est.nome | jsonify }},
"email": {{ include.est.email | jsonify }},
"telefone": {{ include.est.telefone | jsonify }},
"whatsapp": {{ include.est.whatsapp | jsonify }},
"endereco": {{ include.est.endereco | jsonify }},
"categoria": {{ include.est.categoria | jsonify }}
}
15 changes: 3 additions & 12 deletions assets/json/estabelecimento.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,8 @@ layout: compress

{
{% for est in site.estabelecimentos %}
"{{est.nome}}": {
"nome": "{{est.nome}}",
"email": "{{est.email}}",
"telefone": "{{est.telefone}}",
"whatsapp": "{{est.whatsapp}}",
"endereco": {
{% for prop in est.endereco %}
"{{ prop[0] }}": "{{ prop[1] }}"{% if forloop.last == false %},{% endif %}
{% endfor %}
},
"categoria": "{{est.categoria}}"
}{% if forloop.last == false %},{% endif %}
{{ est.nome | jsonify }}:
{% include estabelecimento.json id=forloop.index est=est %}
{% if forloop.last == false %},{% endif %}
{% endfor %}
}

0 comments on commit 977d0b0

Please sign in to comment.