what is the "it" for? #96
-
I seem to have to use it although your examples don't always use it. |
Beta Was this translation helpful? Give feedback.
Answered by
shadowtime2000
Mar 6, 2021
Replies: 2 comments 1 reply
-
@chovy Please use GH discussions for questions, I will be converting this issue to a discussion. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
shadowtime2000
-
It appears that I can modify <%
if (!it.pinyin) {
const r = await fetch(`https://zhres.herokuapp.com/api/vocab/match`, {
method: 'POST',
body: JSON.stringify({ entry: it.chinese }),
headers: { 'Content-Type': 'application/json' }
})
if (r.ok) {
const { result } = await r.json()
if (result[0]) {
it.simplified = result[0].simplified
it.traditional = result.map(r => r.traditional).filter(r => r).filter((a, i, r) => r.indexOf(a) === i)
it.pinyin = result.map(r => r.pinyin).filter((a, i, r) => r.indexOf(a) === i)
it.english = result.flatMap(r => r.english.split('/')).filter((a, i, r) => r.indexOf(a) === i)
}
}
}
if (!it.pinyin) {
it.pinyin = [toPinyin(it.chinese)]
}
%> |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@chovy
it
represents the object in which template data is stored - you can configure it to use a different name or have it dumped in global scope withwith
in a sense.Please use GH discussions for questions, I will be converting this issue to a discussion.