What is x-tmpl?

前端 未结 4 1703
忘了有多久
忘了有多久 2020-11-29 18:02

Was looking for the answer on the net, but couldn\'t find anything. This little snack of code really frustrates me, as I can\'t understand it. (It\'s part of the plugin call

相关标签:
4条回答
  • 2020-11-29 18:17

    The code above references the project Django Jquery File Upload found here https://github.com/sigurdga/django-jquery-file-upload

    The {% %} are Django template tags. For more information visit https://docs.djangoproject.com/en/dev/ref/templates/

    These tags will be parsed by the django templating system

    0 讨论(0)
  • 2020-11-29 18:21

    x-tmpl has no real meaning, it simply stops the browser from interpreting the script as javascript.

    It's mostly used with jquery templates or knockoutjs template binding.

    At some point, a javascript data object will be used in conjunction with the template to render some html. The values in the data object will replace those marked with {%} and similar in the template, with some {%} sections reflecting code flow such as loops etc.

    I'm not sure which templating library uses {%} however, it's not jquery templates, jsrender or knockout. You'd have to check what libraries are being referenced in the sample code.

    0 讨论(0)
  • 2020-11-29 18:21

    So, what type is text/x-tmpl?

    A non-standard one. Looks like a template though.

    What are these {% and %} tags?

    Part of the template language.

    What parser executes this code?

    Probably one written in JavaScript and imported in another <script> element on the same page.

    0 讨论(0)
  • 2020-11-29 18:31

    jQuery-File-Upload has a dependency on JavaScript-Templates which uses the nonstandard text/x-tmpl mime type

    • https://github.com/blueimp/jQuery-File-Upload
    • https://github.com/blueimp/JavaScript-Templates
    0 讨论(0)
提交回复
热议问题