将 HTML 代码转换为 laravel(或任何框架)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19064305/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 08:29:43  来源:igfitidea点击:

Convert HTML code to laravel(or any framework)

laravellaravel-4

提问by MUHAMMED JABIR C

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

我的问题很简单,可能非常基本。将 HTML 页面转换为 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.

在 HTML 页面中,链接就像<a href="about-us.html">,我们必须将其转换<a href="{{ URL::asset('about-us.html')}}">为 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?

现在我手动编辑整个 HTML 代码来实现它。有什么简单的方法可以做到吗?(我在 CodeIgniter 中使用了全部替换)或者避免这种过度工作的最佳方法是什么?设计师和程序员之间还有其他工作流程吗?

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

注意:如果您不太理解这个问题,请在此处发表评论。我会编辑它。:)

回答by Fasil kk

The easiest way is,

最简单的方法是,

  1. Copy all HTML files, and paste into viewfolder.

  2. Change extension and rename(ex, about.htmlto about.blade.php)

  3. Replace all .html with blank, so you <a href='about.html'>will be <a href='about'>

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

  5. Create route for static pages. you can create each routes, but you can crate a single common route for all page, ex

    Route::get('{page_name}', function($page_name)
    {
        //
        return View::make('frontend/'.$page_name);
    });
    
  1. 复制所有 HTML 文件,并粘贴到视图文件夹中。

  2. 更改扩展名并重命名(例如,about.htmlabout.blade.php

  3. 用空白替换所有 .html,这样你<a href='about.html'>就会 <a href='about'>

  4. 将所有其他文件/文件夹(js 文件夹、css 文件夹、图像文件夹等)从根文件夹复制到 public。

  5. 为静态页面创建路由。您可以创建每条路线,但您可以为所有页​​面创建一个通用路线,例如

    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

转换一个完整的5页静态网站仅需5分钟

回答by devo

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,

Laravel 基于Routing. 所以你不能将你的链接转换为,

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

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

注意about-us.html. 而不是这个,你应该这样做,

First make a Routein app/routes.php

首先Route输入app/routes.php

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

Then save your about-us.htmlfile as about.blade.phpin app/views.

然后你保存about-us.html文件about.blade.phpapp/views

And you can make the link like this,

你可以像这样制作链接,

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

For better html conversion, see the HTMLBuilder APIhere.

如需更好的 html 转换,请参阅HTMLBuilder API此处