FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node-htmlprocessor/lib/blocktypes/include.js at master · dciccale/node-htmlprocessor · GitHub
dciccale
/
node-htmlprocessor
Public
Notifications
You must be signed in to change notification settings
Fork
20
Star
47
Code
Issues
0
Pull requests
1
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
node-htmlprocessor
/
lib
/
blocktypes
/
include.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (24 loc) · 849 Bytes
Breadcrumbs
node-htmlprocessor
/
lib
/
blocktypes
/
include.js
Copy path
File metadata and controls
33 lines (24 loc) · 849 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict'
;
var
path
=
require
(
'path'
)
;
var
utils
=
require
(
'../utils'
)
;
module
.
exports
=
include
;
function
include
(
content
,
block
,
blockLine
,
blockContent
,
filePath
)
{
var
base
=
this
.
options
.
includeBase
||
path
.
dirname
(
filePath
)
;
var
assetPath
=
path
.
join
(
base
,
block
.
asset
)
;
var
l
=
blockLine
.
length
;
var
fileContent
,
i
;
if
(
utils
.
exists
(
assetPath
)
)
{
// Recursively process included files
if
(
this
.
options
.
recursive
)
{
fileContent
=
this
.
process
(
assetPath
)
;
}
else
{
fileContent
=
utils
.
read
(
assetPath
)
;
}
// Add indentation and remove any last new line
fileContent
=
block
.
indent
+
fileContent
.
replace
(
/
(
\r
\n
|
\n
)
$
/
,
''
)
;
while
(
(
i
=
content
.
indexOf
(
blockLine
)
)
!==
-
1
)
{
content
=
content
.
substring
(
0
,
i
)
+
fileContent
+
content
.
substring
(
i
+
l
)
;
}
}
return
content
;
}
Back
|
FazBrowse Home
|
New Git URL