0.1.1 • Published 9 years ago

code-injection v0.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

NPM version Dependency Status

소스의 특정 영역에 원하는 컨텐츠를 주입하고자 할 때 사용할 수 잇는 모듈

Install

$ npm install --save code-injection

Usage

코드를 주입하고자 하는 영역을 아래와 같은 형태로 주석 추가

<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <title></title>
  <script src="../../bower_components/jquery/dist/jquery.min.js"></script>
</head>
<body>
  <!-- @injection:id1 -->

  <!-- injection@ -->


  <!-- @injection:id2 -->

  <!-- injection@ -->
</body>
</html>

상단에 지정한 아이디로 codeInjection 생성 후 코드 추가

// load module
var codeInjection = require('code-injection');

// create target read stream
var readStream = fs.createReadStream('test/html/test.html');

// @c
var id1 = new codeInjection('id1');
var id2 = new codeInjection('id2');

id1.inject('line1').inject('line2');
id2.inject('content1').inject('content2');

readStream.pipe(id1).pipe(id2).pipe(process.stdout);

License

MIT © JiTae, Kim