#```js
1 messages · Page 1 of 1 (latest)
There's not enough information to tell. Try putting in a console log between each line of code in the hook and seeing where it gets stuck.
so it seems to be failing at
...
const testSheet = template(context, {
allowProtoMethodsByDefault: true,
allowProtoPropertiesByDefault: true,
});
Is testData undefined?
unless that is undefined (my level of knowledge is still growing so it could very well be) then idk
odd, 'that' was supposed to link to my code above the error message
let testData = {
name: "wow",
sourceUUID: "trent",
editing: false,
versions: [
{
priority: 30,
resources: [
{
img: null,
name: null,
required: null,
sourceUUID: null
}
],
checks: [
{
priority: 30,
skill: "Intimidation",
tools: [
{
name: null,
sourceUUID: null
}
],
prerequisites: [
{
img: null,
name: null,
sourceUUID: null
}
]
}
]
}
]
}
After const context = testData do console.log(testData) that will tell you if it's undefined or not.
Or more specifically do console.log(context) or both.
This is JavaScript 101 btw, not FoundryVTT 101
'consoled' that already as well as several other variables.
context returns the above object just fine
template gives my a handlebars core function
If it does then it can't be failing there because that's the measure of success. So what makes you think it's failing there?
thats where the link in the error message points me, im more inclined to think its due to my hbs though idk how
You can't trust those links. Especially not in Chrome
interesting, i wasn't aware of that, thanks
It also doesn't make sense. If there's an error there, then your testSheet should be undefined because evaluating its value would have failed.
To me it looks like the error is happening in WeaponSheetPF2e._render which means that the weaponsheet is not finding a value that it needs to process.
And render happens long after you get the template, I would expect.
Although I could be wrong about that. I don't actually use the Foundry templating system.
hmm, i did just try with a non weapon, though that doesn't necessarily prove anything, hmm
is there a better alternative then?
i mean at the end of the day all i want is to get html from my hbs then stick it as a tab into the item
(this does work when everything is a mess in one file)
So, something you said doesn't add up for me...
understandable lol
You said: template gives my a handlebars core function So that means to me that your testSheet is a function.
However then you do this: ${testSheet} which is treating it like a string.
i might have a mental thread here, give me a sec. This is what it gives me if u need a reference
e(a,b){return f||(f=d()),f.call(this,a,b)}
and it points to handlebars.min.js
Oh, but I see you're calling template() first. Does that produce a string? If you do console.log(typeof testSheet) after const testSheet... is it a string?
So in the original test case I had an html object as a string which i then inserted via ${}. (e.g: let testSheet = <div>...</div>
As I am converting to the final hbs form from that i didn't change the ${}.
Though idk if thats actually the issue or if im clutching at straws
logging should answer that question for you. I think I'm at the end of my ability to be useful here.
i'll give that a go, but thanks regardless
Otherwise chuck it into ChatGPT and ask what's wrong with your hook
It's good at spotting type errors, which is what this sounds like.
kk
Or turn it into TypeScript if you're feeling masochistic... that also handles types sanely (although everything else about it is insane)