将 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
Convert HTML code to laravel(or any framework)
提问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,
最简单的方法是,
Copy all HTML files, and paste into viewfolder.
Change extension and rename(ex,
about.html
toabout.blade.php
)Replace all .html with blank, so you
<a href='about.html'>
will be<a href='about'>
Copy all other files/folder(js folder, css folder, image folder etc) from the root folder to public.
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); });
复制所有 HTML 文件,并粘贴到视图文件夹中。
更改扩展名并重命名(例如,
about.html
为about.blade.php
)用空白替换所有 .html,这样你
<a href='about.html'>
就会<a href='about'>
将所有其他文件/文件夹(js 文件夹、css 文件夹、图像文件夹等)从根文件夹复制到 public。
为静态页面创建路由。您可以创建每条路线,但您可以为所有页面创建一个通用路线,例如
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 Route
in app/routes.php
首先Route
输入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
.
然后你保存about-us.html
文件about.blade.php
在app/views
。
And you can make the link like this,
你可以像这样制作链接,
{{ HTML::link('about', 'About Us') }}
For better html conversion, see the HTMLBuilder API
here.
如需更好的 html 转换,请参阅HTMLBuilder API
此处。