Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Conversation

@Thram
Copy link

@Thram Thram commented Jul 27, 2015

I found myself trying to embeb my partials templates automatically with this Plugin and I end up with a lot of redundant code that could be process with a simple template, so I added this little tweak and it resolves all my problems. Maybe is useful for somebody else :)

Example:

  • gulpfile.js
...
gulp.task('templates', function () {
    gulp.src(['example/index.html'])
        .pipe(fileinclude({
            template: '<script type="text/template" id="@filename"> @content </script>'
        }))
        .pipe(gulp.dest('example/'));
});
...
  • index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="css/example.css" type="text/css">
    <title></title>
</head>
<body>

@@include('./example-view.html')
<script type="application/javascript" src="js/example.js"></script>
</body>
</html>
  • example-view.html
<div>
   My Template View!
</div>

Result

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="css/example.css" type="text/css">
    <title></title>
</head>
<body>

<script type="text/template" id="example-view">
    <div>
       My Template View!
    </div>
</script>
<script type="application/javascript" src="js/example.js"></script>
</body>
</html>

I hope somebody else find it useful too 😃

Thram added 3 commits July 27, 2015 14:17
- Example: 
gulp.task('templates', function () {
    gulp.src(['example/index.html'])
        .pipe(fileinclude({
            template: '<script type="text/template" id="@filename"> @content </script>'
        }))
        .pipe(gulp.dest('example/'));
});
@TrySound
Copy link
Collaborator

Hi! Thanks for your request. You will be able to use custom processors in 1.* version. But this case are not gulp-file-include way. Sorry.

@TrySound TrySound closed this Jul 27, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants