Include a file: Difference between revisions

Content added Content deleted
(Added Axe)
(jq)
Line 440: Line 440:
===ES6 Modules===
===ES6 Modules===
<lang javascript>import $ from "jquery";</lang>
<lang javascript>import $ from "jquery";</lang>

=={{header|jq}}==

{{works with | jq | with "include" }}

jq 1.5 has two directives for including library files, "include" and "import". A library file here means one that contains jq function definitions, comments, and/or directives.

The main difference between the two types of directive is that included files are in effect textually included at the point of inclusion, whereas
imported files are imported into the namespace specified by the "import" directive. The "import" directive can also be used to import data.

Here we illustrate the "include" directive on the assumption that there are two files:

'''Include_a_file.jq'''
<lang jq>include "gort";

hello</lang>

'''gort.jq'''
<lang>def hello: "Klaatu barada nikto";</lang>

{{ out }}
<lang sh>$ jq -n -c -f Include_a_file.jq
Klaatu barada nikto.</lang>


=={{header|Julia}}==
=={{header|Julia}}==