jabir145
jabir145

Reputation: 310

Convert HTML code to laravel(or any framework)

My question is simple and may be very basic. What is the best way to convert HTML pages to Laravel.?

In HTML pages the links are like <a href="about-us.html">, we have to convert it to <a href="{{ URL::asset('about-us.html')}}"> for Laravel.

Now i am manually editing entire HTML code to achieve it. Is there any short way to do it.?(i used replace all in CodeIgniter) Or What is the best way to avoid this overwork? Any other workflow between designer and programmer?

Note: Please comment here if you dont understand this question well. I will edit it.:)

Upvotes: 8

Views: 20059

Answers (2)

Fasil kk
Fasil kk

Reputation: 2187

The easiest way is,

  1. Copy all HTML files, and paste them into the view folder.

  2. Change all files extensions from .html to .blade.php (eg. about.html to about.blade.php).

  3. Remove the '.html' from all anchors href, so <a href='about.html'> will be <a href='about'>. (Just replace .html with "" ).

  4. Copy all other files/folders (js folder, CSS folder, image folder, etc) from the root folder to the public folder.

  5. Create a route for your static pages. You can create a route for each page or you can create a single common route for all pages, like this.

     Route::get('{page_name}', function($page_name)
     {
         //
         return View::make('frontend/'.$page_name);
     });
    
  • It will take only 5 minutes to convert a complete 5-page static website.

Upvotes: 17

Anshad Vattapoyil
Anshad Vattapoyil

Reputation: 23463

There is no way to do this without editing each and every page.

Laravel is based on Routing. So you can't convert your link to,

<a href="{{ URL::asset('about-us.html')}}">

Note the about-us.html. Instead of this you should do this,

First make a Route in app/routes.php

Route::get('about', function()
{
    return View::make('about');
});

Then save your about-us.html file as about.blade.php in app/views.

And you can make the link like this,

{{ HTML::link('about', 'About Us') }}

For better html conversion, see the HTMLBuilder API here.

Upvotes: 3

Related Questions