mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-12-02 03:38:03 +08:00
Change escapes from '{{}}' to '[[]]' in views
This commit is contained in:
parent
8d1617d1a7
commit
fa9376b89a
@ -25,8 +25,8 @@ static const std::string cxx_end = "%>";
|
||||
static const std::string cxx_lang = "<%c++";
|
||||
static const std::string cxx_view_data = "@@";
|
||||
static const std::string cxx_output = "$$";
|
||||
static const std::string cxx_val_start = "{{";
|
||||
static const std::string cxx_val_end = "}}";
|
||||
static const std::string cxx_val_start = "[[";
|
||||
static const std::string cxx_val_end = "]]";
|
||||
static const std::string sub_view_start = "<%view";
|
||||
static const std::string sub_view_end = "%>";
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
cmake_minimum_required (VERSION 3.2)
|
||||
Project({{ProjectName}})
|
||||
Project([[ProjectName]])
|
||||
|
||||
link_directories(/usr/local/lib)
|
||||
link_libraries(drogon trantor pthread dl)
|
||||
@ -103,4 +103,4 @@ foreach(cspFile ${SCP_LIST})
|
||||
endforeach()
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_executable({{ProjectName}} ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${VIEWSRC} ${PLUGIN_SRC} ${MODEL_SRC})
|
||||
add_executable([[ProjectName]] ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${VIEWSRC} ${PLUGIN_SRC} ${MODEL_SRC})
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* {{filename}}.cc
|
||||
* [[filename]].cc
|
||||
*
|
||||
*/
|
||||
|
||||
#include "{{filename}}.h"
|
||||
#include "[[filename]].h"
|
||||
|
||||
using namespace drogon;
|
||||
<%c++auto namespaceStr=@@.get<std::string>("namespaceString");
|
||||
@ -12,7 +12,7 @@ if(!namespaceStr.empty())
|
||||
$$<<"using namespace "<<namespaceStr<<";\n";
|
||||
%>
|
||||
|
||||
void {{className}}::doFilter(const HttpRequestPtr &req,
|
||||
void [[className]]::doFilter(const HttpRequestPtr &req,
|
||||
const FilterCallback &fcb,
|
||||
const FilterChainCallback &fccb)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
*
|
||||
* {{filename}}.h
|
||||
* [[filename]].h
|
||||
*
|
||||
*/
|
||||
|
||||
@ -18,10 +18,10 @@ namespace {%namespaceName%}
|
||||
{
|
||||
<%c++}
|
||||
$$<<"\n";%>
|
||||
class {{className}} : public HttpFilter<{{className}}>
|
||||
class [[className]] : public HttpFilter<[[className]]>
|
||||
{
|
||||
public:
|
||||
{{className}}() {}
|
||||
[[className]]() {}
|
||||
virtual void doFilter(const HttpRequestPtr &req,
|
||||
const FilterCallback &fcb,
|
||||
const FilterChainCallback &fccb) override;
|
||||
|
@ -3,12 +3,12 @@ using namespace drogon_ctl;
|
||||
%>
|
||||
/**
|
||||
*
|
||||
* {{className}}.cc
|
||||
* [[className]].cc
|
||||
* DO NOT EDIT. This file is generated by drogon_ctl
|
||||
*
|
||||
*/
|
||||
|
||||
#include "{{className}}.h"
|
||||
#include "[[className]].h"
|
||||
#include <trantor/utils/config.h>
|
||||
#include <drogon/utils/Utilities.h>
|
||||
#include <string>
|
||||
@ -17,17 +17,17 @@ using namespace drogon_ctl;
|
||||
auto className=@@.get<std::string>("className");
|
||||
%>
|
||||
|
||||
using namespace drogon_model::{{dbName}};
|
||||
using namespace drogon_model::[[dbName]];
|
||||
|
||||
<%c++for(auto col:cols){
|
||||
%>
|
||||
const std::string {{className}}::Cols::{%col._colName%} = "{%col._colName%}";
|
||||
const std::string [[className]]::Cols::{%col._colName%} = "{%col._colName%}";
|
||||
<%c++
|
||||
}%>
|
||||
<%c++if(@@.get<int>("hasPrimaryKey")<=1){%>
|
||||
const std::string {{className}}::primaryKeyName = "{{primaryKeyName}}";
|
||||
const std::string [[className]]::primaryKeyName = "[[primaryKeyName]]";
|
||||
<%c++}else{%>
|
||||
const std::vector<std::string> {{className}}::primaryKeyName = {<%c++
|
||||
const std::vector<std::string> [[className]]::primaryKeyName = {<%c++
|
||||
auto pkName=@@.get<std::vector<std::string>>("primaryKeyName");
|
||||
for(size_t i=0;i<pkName.size();i++)
|
||||
{
|
||||
@ -38,13 +38,13 @@ for(size_t i=0;i<pkName.size();i++)
|
||||
%>};
|
||||
<%c++}%>
|
||||
<%c++ if(@@.get<int>("hasPrimaryKey",0)>0){%>
|
||||
const bool {{className}}::hasPrimaryKey = true;
|
||||
const bool [[className]]::hasPrimaryKey = true;
|
||||
<%c++ }else{%>
|
||||
const bool {{className}}::hasPrimaryKey = false;
|
||||
const bool [[className]]::hasPrimaryKey = false;
|
||||
<%c++}%>
|
||||
const std::string {{className}}::tableName = "{{tableName}}";
|
||||
const std::string [[className]]::tableName = "[[tableName]]";
|
||||
|
||||
const std::vector<typename {{className}}::MetaData> {{className}}::_metaData={
|
||||
const std::vector<typename [[className]]::MetaData> [[className]]::_metaData={
|
||||
<%c++for(size_t i=0;i<cols.size();i++){
|
||||
auto &col=cols[i];
|
||||
$$<<"{\""<<col._colName<<"\",\""<<col._colType<<"\",\""<<col._colDatabaseType<<"\","<<col._colLength<<","<<col._isAutoVal<<","<<col._isPrimaryKey<<","<<col._notNull<<"}";
|
||||
@ -54,12 +54,12 @@ else
|
||||
$$<<"\n";
|
||||
}%>
|
||||
};
|
||||
const std::string &{{className}}::getColumnName(size_t index) noexcept(false)
|
||||
const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
||||
{
|
||||
assert(index < _metaData.size());
|
||||
return _metaData[index]._colName;
|
||||
}
|
||||
{{className}}::{{className}}(const Row &r) noexcept
|
||||
[[className]]::[[className]](const Row &r) noexcept
|
||||
{
|
||||
<%c++
|
||||
for(auto col:cols)
|
||||
@ -110,7 +110,7 @@ const std::string &{{className}}::getColumnName(size_t index) noexcept(false)
|
||||
$$<<" if(str.length()>=2&&\n";
|
||||
$$<<" str[0]=='\\\\'&&str[1]=='x')\n";
|
||||
$$<<" {\n";
|
||||
$$<<" _"<<col._colValName<<"=std::make_shared<std::vector<char>>(drogon::hexToBinaryVector(str.data()+2,str.length()-2));\n";
|
||||
$$<<" _"<<col._colValName<<"=std::make_shared<std::vector<char>>(drogon::utils::hexToBinaryVector(str.data()+2,str.length()-2));\n";
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
@ -233,7 +233,7 @@ const std::string &{{className}}::getColumnName(size_t index) noexcept(false)
|
||||
}
|
||||
%>
|
||||
|
||||
const std::vector<std::string> &{{className}}::insertColumns() noexcept
|
||||
const std::vector<std::string> &[[className]]::insertColumns() noexcept
|
||||
{
|
||||
static const std::vector<std::string> _inCols={
|
||||
<%c++for(size_t i=0;i<cols.size();i++){
|
||||
@ -251,7 +251,7 @@ const std::vector<std::string> &{{className}}::insertColumns() noexcept
|
||||
return _inCols;
|
||||
}
|
||||
|
||||
void {{className}}::outputArgs(drogon::orm::internal::SqlBinder &binder) const
|
||||
void [[className]]::outputArgs(drogon::orm::internal::SqlBinder &binder) const
|
||||
{
|
||||
<%c++for(auto col:cols){
|
||||
if(!col._isAutoVal&&!col._colType.empty())
|
||||
@ -271,7 +271,7 @@ void {{className}}::outputArgs(drogon::orm::internal::SqlBinder &binder) const
|
||||
%>
|
||||
}
|
||||
|
||||
const std::vector<std::string> {{className}}::updateColumns() const
|
||||
const std::vector<std::string> [[className]]::updateColumns() const
|
||||
{
|
||||
std::vector<std::string> ret;
|
||||
for(size_t i=0;i<sizeof(_dirtyFlag);i++)
|
||||
@ -284,7 +284,7 @@ const std::vector<std::string> {{className}}::updateColumns() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
void {{className}}::updateArgs(drogon::orm::internal::SqlBinder &binder) const
|
||||
void [[className]]::updateArgs(drogon::orm::internal::SqlBinder &binder) const
|
||||
{
|
||||
<%c++
|
||||
for(size_t i=0;i<cols.size();i++)
|
||||
@ -308,7 +308,7 @@ void {{className}}::updateArgs(drogon::orm::internal::SqlBinder &binder) const
|
||||
}
|
||||
%>
|
||||
}
|
||||
Json::Value {{className}}::toJson() const
|
||||
Json::Value [[className]]::toJson() const
|
||||
{
|
||||
Json::Value ret;
|
||||
<%c++for(auto col:cols){%>
|
||||
@ -319,7 +319,7 @@ Json::Value {{className}}::toJson() const
|
||||
<%c++}else if(col._colDatabaseType.find("timestamp")!=std::string::npos||col._colDatabaseType.find("datetime")!=std::string::npos){%>
|
||||
ret["{%col._colName%}"]=get{%col._colTypeName%}()->toDbStringLocal();
|
||||
<%c++}else if(col._colDatabaseType=="bytea"||col._colDatabaseType.find("blob")!=std::string::npos){%>
|
||||
ret["{%col._colName%}"]=drogon::base64Encode((const unsigned char *)get{%col._colTypeName%}()->data(),get{%col._colTypeName%}()->size());
|
||||
ret["{%col._colName%}"]=drogon::utils::base64Encode((const unsigned char *)get{%col._colTypeName%}()->data(),get{%col._colTypeName%}()->size());
|
||||
<%c++}else if(col._colType=="int64_t"){%>
|
||||
ret["{%col._colName%}"]=(Json::Int64)getValueOf{%col._colTypeName%}();
|
||||
<%c++}else if(col._colType=="uint64_t"){%>
|
||||
|
@ -3,7 +3,7 @@ using namespace drogon_ctl;
|
||||
%>
|
||||
/**
|
||||
*
|
||||
* {{className}}.h
|
||||
* [[className]].h
|
||||
* DO NOT EDIT. This file is generated by drogon_ctl
|
||||
*
|
||||
*/
|
||||
@ -26,10 +26,10 @@ using namespace drogon::orm;
|
||||
|
||||
namespace drogon_model
|
||||
{
|
||||
namespace {{dbName}}
|
||||
namespace [[dbName]]
|
||||
{
|
||||
|
||||
class {{className}}
|
||||
class [[className]]
|
||||
{
|
||||
public:
|
||||
struct Cols
|
||||
@ -49,7 +49,7 @@ auto cols=@@.get<std::vector<ColumnInfo>>("columns");
|
||||
<%c++if(@@.get<int>("hasPrimaryKey")<=1){%>
|
||||
const static std::string primaryKeyName;
|
||||
<%c++if(!@@.get<std::string>("primaryKeyType").empty()){%>
|
||||
typedef {{primaryKeyType}} PrimaryKeyType;
|
||||
typedef [[primaryKeyType]] PrimaryKeyType;
|
||||
const PrimaryKeyType & getPrimaryKey() const;
|
||||
<%c++}else{%>
|
||||
typedef void PrimaryKeyType;
|
||||
@ -77,8 +77,8 @@ auto cols=@@.get<std::vector<ColumnInfo>>("columns");
|
||||
|
||||
PrimaryKeyType getPrimaryKey() const;
|
||||
<%c++}%>
|
||||
{{className}}(const Row &r) noexcept;
|
||||
{{className}}() = default;
|
||||
[[className]](const Row &r) noexcept;
|
||||
[[className]]() = default;
|
||||
|
||||
<%c++
|
||||
for(auto col:cols)
|
||||
@ -119,7 +119,7 @@ auto cols=@@.get<std::vector<ColumnInfo>>("columns");
|
||||
Json::Value toJson() const;
|
||||
|
||||
private:
|
||||
friend Mapper<{{className}}>;
|
||||
friend Mapper<[[className]]>;
|
||||
static const std::vector<std::string> &insertColumns() noexcept;
|
||||
void outputArgs(drogon::orm::internal::SqlBinder &binder) const;
|
||||
const std::vector<std::string> updateColumns() const;
|
||||
@ -147,5 +147,5 @@ auto cols=@@.get<std::vector<ColumnInfo>>("columns");
|
||||
bool _dirtyFlag[{%cols.size()%}]={ false };
|
||||
};
|
||||
|
||||
} // namespace {{dbName}}
|
||||
} // namespace [[dbName]]
|
||||
} // namespace drogon_model
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* {{filename}}.cc
|
||||
* [[filename]].cc
|
||||
*
|
||||
*/
|
||||
|
||||
#include "{{filename}}.h"
|
||||
#include "[[filename]].h"
|
||||
|
||||
using namespace drogon;
|
||||
<%c++auto namespaceStr=@@.get<std::string>("namespaceString");
|
||||
@ -12,12 +12,12 @@ if(!namespaceStr.empty())
|
||||
$$<<"using namespace "<<namespaceStr<<";\n";
|
||||
%>
|
||||
|
||||
void {{className}}::initAndStart(const Json::Value &config)
|
||||
void [[className]]::initAndStart(const Json::Value &config)
|
||||
{
|
||||
/// Initialize and start the plugin
|
||||
}
|
||||
|
||||
void {{className}}::shutdown()
|
||||
void [[className]]::shutdown()
|
||||
{
|
||||
/// Shutdown the plugin
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
*
|
||||
* {{filename}}.h
|
||||
* [[filename]].h
|
||||
*
|
||||
*/
|
||||
|
||||
@ -18,10 +18,10 @@ namespace {%namespaceName%}
|
||||
{
|
||||
<%c++}
|
||||
$$<<"\n";%>
|
||||
class {{className}} : public Plugin<{{className}}>
|
||||
class [[className]] : public Plugin<[[className]]>
|
||||
{
|
||||
public:
|
||||
{{className}}() {}
|
||||
[[className]]() {}
|
||||
/// This method must be called by drogon to initialize and start the plugin.
|
||||
/// It must be implemented by the user.
|
||||
virtual void initAndStart(const Json::Value &config) override;
|
||||
|
@ -5,7 +5,7 @@
|
||||
%>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{ title }}</title>
|
||||
<title>[[ title ]]</title>
|
||||
</head>
|
||||
<body>
|
||||
<%view header %>
|
||||
|
Loading…
Reference in New Issue
Block a user