I bet you haven't heard of this cool HTML tag & trick!

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ก.ย. 2024
  • Today we're going to look at the html template tag. It's a tag that sort of does literally nothing! Meaning it makes all of the html/css/js that's inside of it do nothing, not even visible!
    Learn about this fancy html tag and how you can leverage it for some fairly common use cases.
    💖 SUBSCRIBE (Please) 💖
    www.youtube.com...
    🌐 Website 🌐
    followandrew.dev
    📢 Social Media 📢
    TWITTER (@followandrewedu) ➞ / followandrewedu
    #html #followandrew

ความคิดเห็น • 25

  • @demarcorr
    @demarcorr หลายเดือนก่อน +1

    i was using a clever placement of tags and regex to match and capture different chunks of html and just += on the innerHTML property 😅but knowing this seems so much better

  • @mdbdrrhm
    @mdbdrrhm ปีที่แล้ว

    How or can one use it in ReactJS?

  • @nullzero9224
    @nullzero9224 8 หลายเดือนก่อน +4

    Nice. A small note regarding defer and type="module". They should not come together. When you declare a script as of type "module" , the processing of the script contents is deferred.The charset and defer attributes have no effect according to MDN docs. Its only enough to use defer

    • @FollowAndrew
      @FollowAndrew  7 หลายเดือนก่อน

      Good to know!

  • @mnsko-qs3vl
    @mnsko-qs3vl 23 วันที่ผ่านมา

    This was really helpful in understanding the template tag. Thanks a lot!

  • @Vortexo07
    @Vortexo07 5 หลายเดือนก่อน +1

    Hello
    I've made a e-commerce site on which the products section is made with template tag but unfortunately I don't know why, upon hosting on internet, the contents of the template dissappears even tho it works perfectly fine while normally...
    What could be the issue...I REALLY APPRECIATE your help! 😢

    • @FollowAndrew
      @FollowAndrew  4 หลายเดือนก่อน +1

      Not sure there? Check casing for all code, var names etc. I've seen casing issues work locally, but not live

  • @mikaelfarro
    @mikaelfarro ปีที่แล้ว +4

    I usually use `` in js to make html then add it to innerHTML of a created element

    • @FollowAndrew
      @FollowAndrew  ปีที่แล้ว +1

      Good tip here, the template literals are great especially if needing to pass in dynamic data

    • @tochimclaren
      @tochimclaren 3 หลายเดือนก่อน

      Be careful how you use innerHTML

  • @BordinX
    @BordinX 9 วันที่ผ่านมา

    teste

  • @Tony.Nguyen137
    @Tony.Nguyen137 ปีที่แล้ว +1

    Which performs better?
    1. Innerthtml = `…`;
    2. template tag or
    3. your first solution with create Element, addClass…
    Or it doesnt matter?

    • @constantine9074
      @constantine9074 ปีที่แล้ว +3

      as far as I know innerHTML has some security issues , till today I was using always createelement and appendchild (which is lil bit more code)

  • @photoinshot1355
    @photoinshot1355 ปีที่แล้ว +1

    Brilliant thanks! Did not know anything about the Template tag.

  • @gioba4912
    @gioba4912 ปีที่แล้ว +1

    Genius!
    You're the BEST! This was my intro to Template Tag.

  • @MattCurney
    @MattCurney ปีที่แล้ว

    Cool! This is supported in all browsers yeah?

    • @FollowAndrew
      @FollowAndrew  ปีที่แล้ว +1

      Yep 97.77% coverage as of this comment.

  • @suvrotica
    @suvrotica 8 หลายเดือนก่อน

    New for me loved it

  • @kevinwiens4804
    @kevinwiens4804 ปีที่แล้ว

    Thanks Andrew this is sweet!

  • @paevents8064
    @paevents8064 ปีที่แล้ว

    An awesome tutorial

  • @mikaelfarro
    @mikaelfarro ปีที่แล้ว

    Thanks

  • @peterloader974
    @peterloader974 8 หลายเดือนก่อน

    And if each card is different, what then? It seems redundant to me.

    • @Markus-iq4sm
      @Markus-iq4sm 7 หลายเดือนก่อน

      then you do not have a `template`, obviously

    • @Silverflame1
      @Silverflame1 5 หลายเดือนก่อน

      You can change the content of the cloned template with JavaScript. I suppose it's easier then always creating new elements.

  • @makingtheweb6620
    @makingtheweb6620 ปีที่แล้ว +1

    I am going to suggest that the spec needs to ban outright divs as people use them in demos. The title doesn't fit the video as it goes off course about JavaScript and wasn't what I was looking for in search.