#```js

1 messages · Page 1 of 1 (latest)

timid raptor
#

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.

compact hazel
#

so it seems to be failing at

...
  const testSheet = template(context, {
    allowProtoMethodsByDefault: true,
    allowProtoPropertiesByDefault: true,
  });
timid raptor
#

Is testData undefined?

compact hazel
#

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
            }
          ]
        }
      ]
    }
  ]
}
timid raptor
#

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

compact hazel
#

'consoled' that already as well as several other variables.

#

context returns the above object just fine

#

template gives my a handlebars core function

timid raptor
#

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?

compact hazel
#

thats where the link in the error message points me, im more inclined to think its due to my hbs though idk how

timid raptor
#

You can't trust those links. Especially not in Chrome

compact hazel
#

interesting, i wasn't aware of that, thanks

timid raptor
#

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.

compact hazel
#

hmm, i did just try with a non weapon, though that doesn't necessarily prove anything, hmm

compact hazel
#

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)

timid raptor
#

So, something you said doesn't add up for me...

compact hazel
#

understandable lol

timid raptor
#

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.

compact hazel
timid raptor
#

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?

compact hazel
#

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

timid raptor
#

logging should answer that question for you. I think I'm at the end of my ability to be useful here.

compact hazel
#

i'll give that a go, but thanks regardless

timid raptor
#

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.

compact hazel
#

kk

timid raptor
#

Or turn it into TypeScript if you're feeling masochistic... that also handles types sanely (although everything else about it is insane)