I’m trying to create multiple sizes of an ad in a single Hype document. This would work fine except that on output I need the HTML content to be different for each one. Is this possible? I know there has been previous discussion about being able to access scene variables such as layout size to include as metadata, but it doesn’t appear that you can even have a different per Scene either. Am I missing something or is this a feature that hasn’t been added yet?
I think you can possibly do this with the new export scripts
I would expect that a script would add the UI to Hype to allow custom code to be added per export. But as I say it is all new…
It’s funny you mention that because I got the update notification immediately after posting that. Unfortunately I had a job due out today so I didn’t have time to look into it and see if I can modify the script to inject the Layout height and width variables. Any devs care to weigh in?
I suppose this would be technically possible, though depending on your needs (like if it is just JS) it may be easier to conditionalize a single head html. The export scripts are meant to be fairly generic and operate across different .hype documents, so if you need specific head HTML on your document this would be overkill vs. simply modifying the HTML after export. I’ll also note that each scene can have its own set of layouts, so they aren’t a document-level construct (though Hype does try to make it easy since the common use case is each scene having the same layouts).
So that said, if what you’re going to be making is pretty generic, then the mechanism you’d probably want to use in the Export Script is in looking at the file from the
export_info_json_path argument in the final
modify_staging_path call. This is a JSON file which contains keys
main_container_height. If you’re using advanced export and using the per-layout exports, then these will be different for each layout and you can conditionalize on the size. There’s existing code in the sample export script to insert into the head, so you can simply choose what you want added there.
Hope that helps!