brlinker

File link system One change made everywhere

Usage no npm install needed!

<script type="module">
  import brlinker from 'https://cdn.skypack.dev/brlinker';
</script>

README

brLinker

brLinker It helps you to call files inside html or php so that you can easily change them from one place and also provide you with the ability to collect javascript or css files or any type of files into one file in the order you need the best thing in this is it so fast and its best for low performance

Installation

Use npm to install brLinker.

npm install brlinker

Usage

Javascipt

const brLinker = require('brLinker');
//import brLinker
//pages that you created 
console.log(brLinker.pages); //you can also define your pages here [object]
//options default true at all
brLinker.options = {
   pretty : true // export a pretty html or php file syntax
   watchDirs : true // watch new files in watching dirs 
}

//build a page TASKS
let pageName = brLinker.newPage('pageName',  page=> {
     //set page settings
     page.data = {}//data for including components in the page
     page.src('sourceFile.(php/html)', 'outputFile.(php/html)')
     page.compress('taskName(css/js ...)',
                  ['file1', 'file2', ...] ,
                   'outputFile.(js/css ...)')
})
//run page tasks 
pageName.export() // run export task [src]
pageName.runTask('taskName'); //run compress task BY its name
pageName.runAll() // run all page tasks 
pageName.dataFrom('jsonFilePath'); //get data from a json file

//run all page tasks 
brLinker.runExports() //run all export tasks in All pages
brLinker.runTask('taskName') //run All taks that has this Name i all pages
/* important : your must define this task name in All pages*/
brLinker.OMEGArun() // run all tasks in all pages



//watching tasks 

brLinker.watch('taskName' , PATHS , callbackFunction)
//how to create PATHS to watch


`
   ------------    paths type -------------

  normal path: 'C://dir1/dir2/myfile.html'
-------------------------------------------
  all folder : 'C://dir1/**/myfile.html'
     this mean watch mayfile.html in all folders in dir1
----------------------------------------------
  all file have the same extension : 'C://dir1/*.js'
     this mean watch all files that have .js extension
------------------------------------------------
  exemple : 'C://dir1/**/*.js' 
     this mean all files .js in all folders in /dir1 

`
//PATHS can be a string[one path] or an array[many paths]
 

html /php

normal import


how to import a template html or php
<linker tem="path-of-your-template">
how to import a template many times
<for-linker for="int-number" tem="path-of-your-template">

import with data

This data will come from the page data that was previously defined in JavaScript

in The Template

 <head>
     <title>{d:title}</title>
</head>
 
{d:varName} //set data by this varName

in the soucePage


how to import a template html or php
<linker tem="path-of-your-template" data="head">
how to import a template many times
<for-linker for="multiTitles" tem="path-of-your-template">
multiTitles must be an ARRAY just like you do in for loop

in the json File or JS object

(The data that you entered for the page jsFile:[page.data / dataFrom()])

{
  "head": {
       "title": "home page or any title "
    }, 
   "multiTitles" : [
         {
       "title": "home page or any title 1"
         },{
       "title": "home page or any title 2"
         },{
       "title": "home page or any title 3"
        },{
       "title": "home page or any title 4"
        }
    ]
}

OUTPUT

 <head>
     <title>home page or any title </title>
</head>
 <head>
     <title>home page or any title 1</title>
</head>
 <head>
     <title>home page or any title 2</title>
</head>
 <head>
     <title>home page or any title 3</title>
</head>
 <head>
     <title>home page or any title 4</title>
</head>

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

email : abdellawy553@gmail.com

License

MIT