Comments (4)
Thank you for the example. I started from scratch and it worked!
from gulp-file-include.
The @@webRoot
variable is set automatically. Just use it in your template wherever you need a relative path to the source root.
For example, the src
and href
attributes below both use @@webRoot
:
<!DOCTYPE html>
<html>
<head>
<link type=stylesheet src=@@webRoot/css/style.css>
</head>
<body>
<h1>Support Contact Info</h1>
<footer><a href=@@webRoot>Home</a></footer>
</body>
</body>
</html>
Depending on how deep your template is in the folder structure, the resulting HTML will look something like:
<!DOCTYPE html>
<html>
<head>
<link type=stylesheet src=../../css/style.css>
</head>
<body>
<h1>Support Contact Info</h1>
<footer><a href=../..>Home</a></footer>
</body>
</body>
</html>
For a working example that's part of a project, see:
https://github.com/dnajs/data-dashboard/blob/main/src/web-app/html/doc-begin.html#L14-L18
from gulp-file-include.
I thought that would be the case but somehow it doesn't work for me.
This is the structure I have:
dist/index.html
dist/docs/index.html
But @@webroot output is same for both and is: "./"
Though it's supposed to be "../" on files inside docs directory.
Maybe I'm missing something somewhere?
from gulp-file-include.
Here's a correctly working example of the @@webRoot
variable that is used in a template at two different levels:
website/root/index.html (higher)
https://github.com/dnajs/dna.js/blob/main/website/root/index.html#L1
website/root/tutorial/index.html (deeper)
https://github.com/dnajs/dna.js/blob/main/website/root/tutorial/index.html#L1
You may have encountered a bug that needs fixing, but it's hard to know without seeing code to replicate the problem.
One possibility (but it's just a wild guess) is that your gulpfile.js is actually running two separate tasks for the output, and the source root for each of the two tasks is the folder containing its respective index.html files.
from gulp-file-include.
Related Issues (20)
- Postfix
- Support recursive include? HOT 1
- Multiline in variable and json error HOT 1
- Can I use different styles for different source files?
- More error info
- How to loop array of objects if it is inside array of objects in the same JSON file?
- could i config custom `@@webRoot` or add `@@urlRoot` ? HOT 6
- Filters documentation
- Is not difined in IF statement HOT 2
- Question: Extension support in vscode
- Include with part of the JSON HOT 1
- nested for loop, inner variable is not defined HOT 1
- Can html page files be generated in batches? HOT 1
- Invalid character error HOT 1
- Build only the files that will be changed
- Detect which file have an error
- Fix : invalid characters in JSON5 HOT 2
- json not work in loop HOT 1
- Pass variables to child include
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp-file-include.