Sunday, 11 June 2017

How to write into a file in node.js

I have some css like below

<style amp-custom>
     form.amp-form-submit-success [submit-success],
     form.amp-form-submit-error [submit-error]{
     margin-top: 16px;
     }
     .bottommargin10{margin-bottom:10px;}
        .comment-msg {
            margin-top: 5px;
            margin-bottom: 0;word-break:break-all;    color: #555;font-size:14px;
        }
        .paddingleft10{padding-left:10px;}
        form.amp-form-submit-success > textarea {
          display: none
        }
        .align-left: {
          margin-left: 898px;
        }
        .button {
            background-color: #4CAF50; /* Green */
            border: none;
            color: white;
            padding: 15px 32px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
            margin: 4px 2px;
            cursor: pointer;
        }
  </style>

I am creating a new html file whenever the i create a new blog in my site.

Here is the code,

 blogs.findOne({blog_id: id}).exec(function (err, results) {
        if (err) {
            helper.logs('editBlog','blog',err,'console');  
            return console.error(err);
        }
        if (results) {
            var fileName = 'public/test_amp/'+results.blog_id+'.html';
            var stream = fs.createWriteStream(fileName);
        }
   });

So whenever ii find a blog by id I should create a new html page.Every page should have a css and that is in common for all pages.SO How can I write this long css into the file?Can anyone please suggest me the best way of doing this



via TSR

No comments:

Post a Comment