Template engine details: import resource files

Source: Internet
Author: User
The traditional method of importing external JS and CSS resource files is directly used in the Template File: The traditional method of importing external JS and CSS resource files is directly used in the template file:
The template engine that copies the code ThinkPHP provides specialized labels to simplify the preceding import. [-More-] the first import tag is the import tag. the import method adopts the namespace method similar to the import function of ThinkPHP. for example:
The default Type attribute of the copied code is js, so the following effects are the same:
The copy code also supports batch import of multiple files, for example:
When copying code to import an external CSS file, you must specify the value of the type attribute, for example:
Copy the code above. the default import Start Path is the Public directory under the root directory of the website. to specify other directories, you can use the basepath attribute, for example:
Copy the code. if the imported file contains ".", you can use:
Copy the code to import the/Public/Js/Util/Array. min. js resource file.
You can also import the version number of a resource file, for example:
Copying code can also be supported when multiple files are imported.
You can copy the improt label to determine whether to load the code. for example, you can first determine whether the name variable is set:
Copy the code or use functions that are more complex:
The template cache after the compiled copy code is:
  1. Script
Copy the code load tag. The second one is the load tag. import the public JS or CSS of the current project through URL, for example:
The copy code can be replaced by a special template tag in the href attribute, for example:
You do not need to specify the type attribute when copying the Load tag of the code. The system automatically determines the type based on the suffix.
Of course, the load tag also supports conditional judgment calls:
The replication code system also provides two label aliases. js and css are used in the same way as load. for example:
The copy code load tag also supports importing multiple resource files at the same time, or even different types of resource files:
Copy code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.