Comments (5)
The first stab looks like this but it fails to render URLs correctly because of golangs html/template security model(and rightfully so), it should probably be fixed upstream by exposing RDF URIs as template.URL although it might not be a good solution it seems: https://play.golang.org/p/carDm1O3l26
Alternativity a child one should be able to a typed string to a child template somehow. Dead end
<script type="application/ld+json">
{{ $global := metadata }}
{
"@context": "https://schema.org",
"@type": "Organization",
"description": "{{ .orgDescription }}}",
{{ if .email }}"email": "{{ replace .email "mailto:" "" 1 }}",{{ end }}
"additionalType": "{{ .type }}",
"url": "{{ $global.root_url }}/{{ .countryURL }}/{{ .qid }}/",
"sameAs": [{{ if $socialAccounts }}{{ range $socialAccounts }}"{{ .url }}",{{ end }}{{ end }}"http://wikidata.org/entity/{{ .qid }}"],
"name": "{{ .orgLabel }}"
}
</script>
from website.
Two new things to test:
- casting to template.URL
- casting to template.JS
from website.
golang/go#17894 (comment)
https://github.com/gohugoio/hugo/blob/3d5dbdcb1a11b059fc2f93ed6fadb9009bf72673/tpl/safe/safe.go#L40
from website.
One way seems to be to trick the template into believing that it's not performing rendering inside of a script tag:
{{"<script"}} type="application/ld+json">
{{- $socialAccounts := query "account-data" .qid.String -}}
{{- $global := metadata }}
{
"@context": "https://schema.org",
"@type": "Organization",
"description": "{{ .orgDescription }}",
{{- if .email -}}"email": "{{ replace .email "mailto:" "" 1 }}",{{- end }}
"additionalType": "{{ .type }}",
"url": "{{ $global.root_url }}{{ template "get-country-url.html" .country }}/{{ .qid }}",
"sameAs": [{{ if $socialAccounts }}{{ range $socialAccounts }}"{{ html .url}}",{{ end }}{{ end }}"http://wikidata.org/entity/{{ .qid }}"],
"name": "{{ .orgLabel }}"
}
</script>
Go templates still however escapes the {{"<script"}}
part...
from website.
Closed by b37e1c2
from website.
Related Issues (20)
- Add Digital Public Goods status to footer
- Add Bermuda
- Add "improve data", "discuss", etc to create issue templates HOT 3
- Selfhost footer images HOT 1
- Stray </div> tag on landing page. HOT 2
- Hide the "View on a map" button if JavaScript is disabled HOT 2
- Allow to sort lists based on the platform column
- Add a read more on Wikipedia button to country pages HOT 5
- Tweet/Toot about organizations that have good data HOT 1
- Make a poster for WikiconNL HOT 4
- Pages can sometimes have empty p tags
- The statistics view should display contact points per country
- Add official website in TSV export HOT 3
- Add Govdirectory to OKFN projects HOT 1
- Submit session proposal for Mozilla Festival 2023 HOT 1
- Unable to fetch accout data from Wikidata HOT 4
- Alternative approach to topics HOT 4
- Make submission to Wikimania 2023 HOT 4
- Inform user of replaced organizations
- Office holders should be humans
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from website.