Show 2 areas of code should be simple

I created a user function and I can see it and it works fine.

Now I am trying to bring the return variable and use it in a different part of the template.

<%* 
let code = await tp.user.chooseCodeBlock(tp);
%>


``<%${code}%>
``

I think it should suffice with the latter part being: <% code %>, or if you got your formatting somewhat askew something like:

<%* 
let code = await tp.user.chooseCodeBlock(tp);
%>

```<% code %>
```
Bonus tip: How to present code properly in a forum post

If you want to showcase either markdown, or code blocks, or dataview queries properly in a forum post, be sure to add one line before and one life after what you want to present with four backticks, ````. This will ensure that any other backticks (like for code blocks) is properly shown.

Thank you, I got it working 95%

Here is my new issue:

<%* 
let code = await tp.user.chooseCodeBlock(tp);
%>


```<% code %>
${tp.file.cursor()}
```

That one should also be within the normal templater syntax:

<%* 
let code = await tp.user.chooseCodeBlock(tp);
%>

```<% code %>
<% tp.file.cursor() %>
```

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.