Coder Social home page Coder Social logo

Comments (4)

elemis avatar elemis commented on June 20, 2024 1

Thank you for the example. I started from scratch and it worked!

from gulp-file-include.

dpilafian avatar dpilafian commented on June 20, 2024

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.

elemis avatar elemis commented on June 20, 2024

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.

dpilafian avatar dpilafian commented on June 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.