我们当前的站点被分解为各种易于使用的PHP包含,这些使用其中一个漂亮的PHP模板库汇集在一起.
我们目前使用Ant构建来优化大多数关于连接,缩小和图像优化的前端代码.我们想要做的是添加一个额外的Ant任务,该任务将解析PHP模板文件并将静态HTML页面输出到我们的构建文件夹中.
有人能指出我正确的方向吗?
下面我想要实现的一个非常基本的例子:
构建之前的PHP模板
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/tpl/basic-template.php');
startblock('title');
echo 'Test page';
endblock();
startblock('content');
include($_SERVER['DOCUMENT_ROOT'].'/incl/content-fragment.php');
endblock();
?>
Run Code Online (Sandbox Code Playgroud)
是否可以通过Ant任务创建上述静态HTML页面,如下所示:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test page</title>
</head>
<body>
<p>This paragraph was the contents of content-fragment.php</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我是一个铁杆菜鸟,所以下面可能是缺乏理解,但我一直在寻找/阅读整天,似乎无法找到解决方案.
我有两个模型 - 项目和技术:
项目:
class Project < ActiveRecord::Base
attr_accessible description, :name
has_and_belongs_to_many :technologies, :join_table => :projects_technologies
end
Run Code Online (Sandbox Code Playgroud)
技术:
class Technology < ActiveRecord::Base
attr_accessible :abbr, :description, :name
has_and_belongs_to_many :projects, :join_table => :projects_technologies
end
Run Code Online (Sandbox Code Playgroud)
我的Create_Projects_Technologies迁移如下:
class CreateProjectsTechnologies < ActiveRecord::Migration
def self.up
create_table :projects_technologies, :id => false do |t|
t.references :project
t.references :technology
end
add_index :projects_technologies, [:project_id, :technology_id]
add_index :projects_technologies, [:technology_id, :project_id]
end
def self.down
drop_table :projects_technologies
end
end
Run Code Online (Sandbox Code Playgroud)
然后,我使用Active Admin使用以下格式创建和编辑项目模型:
ActiveAdmin.register Project do
form do |f|
f.inputs "Project attributes" do
f.input …Run Code Online (Sandbox Code Playgroud)