Embed Link

When readers click on an embed link a new card loads at the position of the link, i.e. directly inside the current card. That means, embed links are like normal links but with a special loading behavior.

Create an embed link

Embed links are written like normal links, but with an additional building block. This block contains a special keyword: embed.

:CARD: healthy special

You stop by Alfonso's. The menu says: "Sunday Special: Salami Supreme."

:LINK: (Show nutritional information) | nutInfo | embed

"Hey Alfonso, I'll have the special."
"Coming up," Alfonso cheers.

:CARD: nutInfo
//The Salami Supreme is made with: quite a bit of protein, a pinch of good fats, several spoons of energizing carbs, two handful of sliced salami, and a bucket of love.

When you click an embed link, the target card does not replace the current one. Rather, the target card gets displayed inside the current card at the position of the link.

Imagine embed links as a supplement to the current card. They are meant for additional or belated content. Consequently, they do not replace the old card or disable other links.

The embed keyword only works as the third building block on a link. You must write your link with separate blocks for linktext and linktarget.

Workflow tip: Instead of the keyword embed you can use the shorthand e.

Sticky embed links

When readers click on an embed link the link disappears. If you want the link's text to remain visible after clicking, you can add a special keyword: sticky.

:CARD: pizza composition

"The special it is. Anything else?" Alfonso always makes you feel like his favorite customer.

:LINK: "I think I'd like some extra peppers today." | peppers | embed,sticky
:LINK: "Some gorgonzola on top, please, if it's no trouble." | gorgonzola | embed,sticky

Your mouth waters as Alfonso put this delicious pie into the oven.

:CARD: peppers
:SWITCH: peppers
"Extra peppers, no problem," says Alfonso as he places them carefully.

:CARD: gorgonzola
"Good choice. That's my favorite kind of cheese, too."
:CHECK: peppers
Alfonso picks up the peppers, lays down some cheese and redistributes the peppers as only he can. Perfect!

Practice tip: Click the first embed link in the example above, then the second. Afterwards, hit reset and go again. But this time click the second link before the first. See what happened?

Workflow tip: Instead of the keyword sticky you can use the shorthand s. Just like the keywords, their shorthands must be separated with a comma: e,s.

Practice tip: If :SWITCH: and :CHECK: are new to you, read up on switch lines and how to check a switch.

Embed links inside paragraphs

Like normal links embed links can occur inside a paragraph. If they do, their target card gets embedded below that paragraph.

:CARD: monthly review

Looking back you realize that you've had Alfonso's Sunday Special :LINK: four times|four|embed:: this month, each time with :LINK:extras|extras|embed::.
That was a good month indeed.

:CARD: four
//Some might say that doing your review of the month on the 15th is a little early. But you don't.

:CARD: extras
//It surely is okay to make a good thing even better if you can.

The rule of thumb is that an embedded card gets loaded directly below its embed link. In this example that means below the paragraph with the embed link.

This creates a situation where the order in which the links are clicked affects the order of paragraphs in the resulting text.

Embed link shorthands

You can also create embed links with the :EMBED: tag or the short tag :E:. These links do not need the embed keyword.

Here's an example with a variety of embed links:

:CARD: diary entry
Dear diary,
:EMBED: today I had the special at Alfonso's. | idea | s

You see, this was an especially pizzicatorious day.

:CARD: idea
It was so tasty that it gave me a marvelous idea.
:E: (Which?) | upside down

:CARD: upside down
Why not replace the dough with salami and use small pieces of dough crust as toppings?
|| And what did Alfonso think? | happy | e,s

:CARD: happy
I spoke with him about my idea and it made him so happy that he laughed for five minutes straight.

Practice tip: The double pipes || are a valid tag for writing links. Make sure you have a firm grasp of simple links to get the most out of interactions in Hypstory.