Skip to content

Updated version that creates routes (appends to your routes/web.php file) #2

Description

@SSzretter

`@echo off
cd %1
cd resources/views/pages
erase *.blade.php /f
cd %1
cd public/assets/css/
erase laravel-bss.css /f
cd %1
move assets %1/public/
rename *.html *.blade.php
move *.blade.php %1/resources/views/pages

:: CREATE ROUTES FOR LARAVEL TO THE BLADE FILES
setlocal ENABLEDELAYEDEXPANSION
set haveLineMarker=0
set tempFile="web.tmp"
set inFile="web.php"
SET SUBSTRING="~~~~~~~~~~~~~~~~~~~~ DO NOT EDIT THIS OR BELOW THIS LINE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
set myDelim=//!SUBSTRING:"=!
cd %1
cd routes
:: loop route file lines and output to temp file until we reach our delimiter
for /f "tokens=*" %%s in (web.php) do (

Echo "%%s" | find !SUBSTRING!>nul && (
	set haveLineMarker=1
) || (
	:: copy line from original file
	if !haveLineMarker!==0 (
		echo %%s >> !tempFile!
  ) 
)

)

:: write the delimiter
echo !myDelim! >> !tempFile!

:: write out new routes based on the templates created earlier
for %%f in (%1/resources/views/pages/*.blade.php) do (
SET viewName=%%~nf
set viewName=!viewName:.blade=!
set newRouteLine="Route::get('!viewName!.html', function(){return view('pages/!viewName!',[]);});"
set newRouteLine=!newRouteLine:"=!
echo !newRouteLine! >> !tempFile!
)

:: BACK UP EXISTING FILE
ren "!inFile!" "!inFile!%date:7,2%-%date:-10,2%-%date:~-2,2%%time:~0,2%.%time:~3,2%.%time:~6,2%.bak"

:: RENAME TEMP FILE
ren "!tempFile!" "!inFile!"

`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions