is there a way to import html into the template?,

oliver's Avatar

oliver

04 May, 2020 09:49 PM

Hi,
I have been adding to my note types a header for the last months. It's really neat but a pain to manage : each time I move a comma or tweak the format I would have to edit both sides of all my note types.

Currently the header is the following :
<span class=grery>Deck - {{Deck}} {{#Tags}} | Tags - {{clickable:Tags}}{{/Tags}} </span> |
<span class = notOnMobile<u><span class=red>{{info-New?:}}</span>{{info-Review?:}}{{info-Learning?:}}</u> | F={{info-Factor:}}</span> <br>
<span class=orange>{{#Teacher}}Par : <i>{{Teacher}}</i>&nbsp&nbsp&nbsp{{/Teacher}}</span>
<span class=h1>{{#Header1}}<b>{{Header1}}</b>{{/Header1}}</span> <br><br>
<span class=h2>{{Header2}}</span>

It renders as you can see in the attached picture. This allows me to see in real time the ease, to know context right away by looking at tags, card status, decks etc.

Is there a way to import html? Much like for my CSS, I have a __personnalStyling.css inside my media folder and it works like a charm.

That would be incredible if I could do the same with html : if the card template contains {{importHTML}} then import the header located in the media folder. Is there a way that you know of?

Thanks!

  1. 1 Posted by oliver on 04 May, 2020 09:50 PM

    oliver's Avatar

    The attachment was not saved when I failed the captcha, beep boop

  2. 2 Posted by addons_zz on 04 May, 2020 10:43 PM

    addons_zz's Avatar

    You can use JavaScript:
    aqt_data\web\test.html

    <div>hi</div>
    
    front template
    <div id="mypage"></div>
    <script type="text/javascript">
    $(function(){$("#mypage").load("/_anki/test.html")});
    </script>
    
    References: https://stackoverflow.com/questions/8988855/include-another-html-fi...
  3. Support Staff 3 Posted by Damien Elmes on 05 May, 2020 05:42 AM

    Damien Elmes's Avatar

    I'm afraid Anki does not provide any user-facing feature to do this at the moment.

  4. 4 Posted by oliver on 05 May, 2020 09:32 AM

    oliver's Avatar

    Hi,
    Thanks a lot, to both of you for your answers.

    In my opinion, that would be an interesting feature to add, I'm thinking it could interact nicely with the addon ecosystem.

    Have a nice day!

Comments are closed, but you can start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac