You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**deps-dev:** bump chai from 4.3.8 to 4.3.10 ([a0f02551](https://github.com/yukal/gulp-json-loader/commit/a0f02551bddefad86d2864cf1e42527d6ebbed0f))
22
+
-**deps-dev:** bump chai from 4.3.7 to 4.3.8 ([e5d80951](https://github.com/yukal/gulp-json-loader/commit/e5d80951f8f1245879924bd71db2b621e5409d91))
23
+
-**deps-dev:** bump mocha from 10.1.0 to 10.2.0 ([367897bb](https://github.com/yukal/gulp-json-loader/commit/367897bb4ed1b9812edc867a8c1fc18ffa92d974))
24
+
-**deps:** bump decode-uri-component from 0.2.0 to 0.2.2 ([4252fa92](https://github.com/yukal/gulp-json-loader/commit/4252fa92d0e6f31d0d31d22a4e23c4b6fc4b3fdf))
Copy file name to clipboardExpand all lines: README.md
+6-30Lines changed: 6 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,8 @@
1
1
# gulp-json-loader
2
-
A little tool for the [gulp-data](https://www.npmjs.com/package/gulp-data) plugin.
3
-
It useful for automatically data loading in the development including the PUG files.
2
+
A little tool for the [gulp-data](https://www.npmjs.com/package/gulp-data) plugin. It useful for automatically data loading in the development including the PUG files.
4
3
5
4
### What for
6
-
I tried to find any simple solution to assign my variables to a current PUG file in a building
7
-
process, but some of the solutions are the same with solutions between the 2014th and 2019th
8
-
years and, actually do not satisfy my needs as I want. And the most popular solution I have
9
-
found looks like:
5
+
I've tried to find a simple solution for assigning my variables into PUG files in a building process. Some of them have similar examples between the 2014th and 2019th years and don't satisfy my technical needs. The most popular solution I have found looks like this:
10
6
11
7
```javascript
12
8
// Somewhere in gulp task
@@ -16,34 +12,14 @@ found looks like:
16
12
.pipe(data(() =>require('data.json') ))
17
13
```
18
14
19
-
After a while, in search of the solution I have found one more way in solving this decision
20
-
in a [detailed article](https://tusharghate.com/rendering-pug-templates-with-multiple-data-files),
21
-
but still not satisfied.
22
-
23
-
So, what's wrong with these solutions?
24
-
First of all, any time, when the queue reaches to Html part, it starts the merging process of all
25
-
the JSON files. Each any Html file, Carl! It means that sometimes the process is performing
26
-
unnecessary actions. What if you don't need to include the data in some of the Html file, it still
27
-
will run enforced actions, any time, again and again, merge... merge... merge. Yes, you can solve
28
-
it by running a once merge, and then always include it as a combined object from the JSON file, as
29
-
the solution in an article above. But it still not a good solution to including the JSON file there
30
-
where you should not include.
31
-
32
-
And I decided to fix this problem in my vision.
15
+
What's wrong with these examples?
16
+
First of all, each time when the queue reaches the HTML part, it starts the merging process of all the JSON files. It means that sometimes the process is performing unnecessary actions. What if we don't need to include the data for some of the HTML files? Well, it still runs enforced actions at any time. We can solve it by once running merge and then always including it as a combined object from the JSON file. But it is still not a good idea to include the JSON file there where we shouldn't.
33
17
34
18
### How does it work
35
-
When the build process's queue reaches Html, it automatically searches the JSON file with the same
36
-
name as in the directory with Html files, or PUG files (it depends on how you set up your project).
19
+
When the build process queue reaches HTML, it automatically searches the JSON file with the same name as in the directory with kinds of PUG files (it depends on how you set up your project).
37
20
38
21
### Structure
39
-
To automatically asigning data to the pages, you must be following the canonical paths. The
40
-
structure of directory with the JSON files should contains with two required folders inside:
41
-
**pages** and **imports**. The **pages** directory structure must be exactly the same structure as
42
-
the directory with PUG files. Here in example the PUG files located in **html** directory. The
43
-
**imports** directory is provided for the JSON files which you can include as a partial data.
44
-
If you missed any of the JSON files in the data/pages directory, the loading of the JSON files will
45
-
not happen and the error will not rise except one thing - It would not happen if you will not try
46
-
to get the data variable from current context while the building process is running.
22
+
To assign some data inside your pages, you have to follow canonical paths. The directory structure with JSON files must contain two necessary folders inside pages and imports. The "pages" directory structure must have the same structure as the directory with the pug files. In the example below, pug files are placed inside the "html" directory. The "imports" directory is provided for the JSON files, which you can include as partial data. If you've missed any JSON file inside the data/pages directory, the loading of the JSON files will not happen, and the error will not rise except, It will not rise if you do not try to get the data variable from the current context while the building process is running.
0 commit comments