Page 1 of 1

PageInclude

Posted: Sun May 04, 2014 9:20 pm
by eddy
- this function includes file withtout callback
- supported file type : CSS, JS, LESS

Code: Select all

Procedure.i PageInclude(FileName.s, FileType.s="")
  If FileType="" : FileType=GetExtensionPart(FileName) : EndIf 
  Select LCase(FileType)
    Case "less"     
      !$('<link rel="stylesheet/less" type="text/css">').attr('href',v_FileName).appendTo('head');
    Case "css"     
      !$('<link rel="stylesheet" type="text/css">').attr('href',v_FileName).appendTo('head');
    Case "js"     
      !$('<script type="text/javascript"></script>').attr('src',v_FileName).appendTo('head');      
  EndSelect   
EndProcedure

CompilerIf #PB_Compiler_IsMainFile
  
  ; *************************
  ; EXAMPLE - load LESS Css
  ; *************************
  
  PageInclude("https://cdn.rawgit.com/twbs/bootstrap/master/less/variables.less")
  PageInclude("https://cdn.rawgit.com/twbs/bootstrap/master/less/normalize.less")  
  PageInclude("http://cdnjs.cloudflare.com/ajax/libs/less.js/1.7.0/less.min.js")    
CompilerEndIf