program story

C ++ HTML 템플릿 프레임 워크, 템플릿 라이브러리, HTML 생성기 라이브러리

inputbox 2020. 11. 25. 07:56
반응형

C ++ HTML 템플릿 프레임 워크, 템플릿 라이브러리, HTML 생성기 라이브러리


예를 들어 비슷한 C ++ 용 템플릿 / 생성기 라이브러리를 찾고 있습니다. Ruby의 Erb, Haml, PHP의 Smarty 등

루프, if / else, 문자열로의 int 변환 등과 같은 몇 가지 기본 기능을 제공한다면 좋을 것입니다.

각 매개 변수에 대해 일부 함수를 호출하는 대신 해시 맵에서 모든 매개 변수를 전달할 수 있다면 템플릿 렌더링 엔진에 매개 변수를 전달하는 것도 중요합니다.

권장 사항이 있습니까?

Lua와 같은 언어를 포함 할 가능성도 볼 수 있지만 템플릿 라이브러리도 찾지 못했습니다.


언급 된 프로젝트에 대한 빠른 검토.

http://rgrz.tumblr.com/post/13808947359/review-of-html-template-engines-in-c-language

ClearSilver

템플릿 타이 저

  • 사이트 : http://www.lazarusid.com/libtemplate.shtml
  • 프로젝트 : 다운로드 만
  • 그룹 : 없음
  • 라이센스 : 무료 사용
  • 언어 : C (낮은 수준) / C ++ (인터페이스) 혼합
  • 마지막 업데이트 : 알 수 없음
  • 마지막 릴리스 : 알 수 없음
  • 문서 : 없음
  • 커뮤니티 : 없음

HTML 템플릿 C ++

ctpp

  • 사이트 : http://ctpp.havoc.ru/en/
  • 프로젝트 : 다운로드 만
  • 그룹 : 없음
  • 라이센스 : BSD 라이센스
  • 언어 : C API가있는 C ++
  • 마지막 업데이트 : 2011 년 10 월 5 일
  • 최종 릴리스 : 2011 년 10 월 5 일 버전 2.7.2
  • 문서 : 부자
  • 커뮤니티 : 없음

중량

Flate

  • 사이트 : http://flate.dead-inside.org/
  • 프로젝트 : 없음
  • 그룹 : 없음
  • 라이센스 : LGPL v2.1
  • 언어 : C
  • 최종 업데이트 : 2010 년 9 월 4 일
  • 최종 출시 : 2.0, 2010 년 9 월 4 일
  • 문서 : 나쁨
  • 커뮤니티 : 없음

Jinja2C ++


Grantlee 는 Django 템플릿 시스템을 기반으로하는 문자열 템플릿 엔진입니다. C ++ / Qt로 포팅됩니다.


NLTemplate 은 Django와 유사한 구문을 가진 작은 C ++ 템플릿 라이브러리입니다.

  • 가변 교체
  • 반복 가능 또는 선택적 블록
  • 파일 포함
  • MIT 라이센스
  • 외부 의존성 없음
  • 모든 프로젝트에 쉽게 추가 할 수있는 단일 소스 파일

면책 조항 : 저는 저자입니다.


Wt ( 'witty'로 발음)는 웹 애플리케이션을 개발하고 배포하기위한 C ++ 라이브러리 및 애플리케이션 서버입니다. 프로그래밍 방식을 강요하는 '프레임 워크'가 아니라 라이브러리입니다.


CTPP 는 C ++로 작성된 매우 빠르고 강력한 라이브러리입니다. Perl, PHP 및 Python에 대한 바인딩이 있습니다.


ClearSilver 는 c. 다음 은 clearsilver를 사용하는 기존 웹 사이트 목록입니다. 그러나 나는 그것을 직접 사용하지 않습니다.


페이스 북의 형식 :

std::cout << format("The answers are {} and {}", 23, 42); 
// => "The answers are 23 and 42"

std::map<std::string, std::string> m { {"what", "answer"}, {"value", "42"} }; 
std::cout << vformat("The only {what} is {value}", m); 
// => "The only answer is 42"

ffead-cpp 프레임 워크에서 제공하는 템플릿 엔진과 동적 C ++ 페이지를 사용해 보았습니다. 예제 구현이 위키에 표시됩니다.


ctemplate

https://code.google.com/p/ctemplate/?redir=1

새로운 BSD 라이선스


어떻게 든 원래 검색 할 때 NLTemplate을 놓 쳤고 NLTemplate과 비슷한 사용 사례로 내 자신의 C ++ 템플릿 엔진을 작성했습니다. :-)

https://github.com/hughperkins/Jinja2CppLight

  • Jinja2와 유사한 구문
  • 가볍고 부스트, qt 등에 대한 종속성 없음 ...
  • 변수 대체
  • for 루프
    • 중첩 된 for 루프 포함 :-)

Jinja2C ++

기술:

  • C ++ 14 / 17 라이브러리
  • 메인 스트림 컴파일러 (Visual C ++, gcc, clang) 지원
  • 사용하기 쉬운 인터페이스.
  • Jinja2 사양 준수 http://jinja.pocoo.org/docs/2.10/
  • 템플릿 및-매개 변수 모두에 대해 좁은 및 넓은 문자열을 모두 지원합니다.
  • C ++ 유형 및 인기있는 json 라이브러리 (nlohmann, RapidJson)에 대한 기본 제공 리플렉션.
  • 사용자 정의 콜 러블.
  • 필터링 ( '|'연산자를 통해) 및 'if'- 표현이있는 강력한 전체 기능의 Jinja2 표현식.
  • Jinja2 태그의 큰 세트에는 매크로 및 템플릿 확장이 포함됩니다.
  • 풍부한 오류보고.

여기 에서 C ++ 용 jade모델로 한 무언가를 개발했습니다 . 간단하지만 강력한 입력 언어를 사용하고 HTML을 스트림에 쓰는 단일 C ++ 템플릿 함수를 만듭니다.

< html
  < h1 The title is ${{ params["title"] }}& >
    < ul >
    & for(int i = 0; i < boost::get<int>(params["items"]); ++i) {
      < li Item ${{ i }}$ >
    & }
>
  • Variable replacement
  • User defined code blocks
  • harvests full power of c++ (loops, variable declarations, you name it)
  • Super easy to integrate into source builds
  • Everything possible done at compile time
  • No intermediate format (straight c++)
  • Easy to debug (because c++ output)
  • No external dependencies
  • Super tiny less than 600 lines of c++
  • GPL licensed

Templtext is a small C++ text template processing library. It supports bash-like variables (%VAR or %{VAR}). But the main feature is a support of user defined functions. The library was created by me.

  • Template parsing
  • Variable replacement
  • User defined functions in template
  • C++11
  • GPL license

need BOOST regex library, but it will be replaced with std::regex in the next version

Example 1:

using namespace templtext;

Templ * t = new Templ( "Dear %SALUTATION %NAME. I would like to invite you for %TEXT. Sincerely yours, %MYNAME." );

std::map<std::string, std::string> tokens01 =
{
        { "SALUTATION", "Mr." },
        { "NAME", "John Doe" },
        { "TEXT", "an interview" },
        { "MYNAME", "Ty Coon" }
};

std::map<std::string, std::string> tokens02 =
{
        { "SALUTATION", "Sweetheart" },
        { "NAME", "Mary" },
        { "TEXT", "a cup of coffee" },
        { "MYNAME", "Bob" }
};

std::cout << t->format( tokens01 ) << std::endl;
std::cout << t->format( tokens02 ) << std::endl;

Output:

Dear Mr. John Doe. I would like to invite you for an interview. Sincerely yours, Ty Coon.
Dear Sweetheart Mary. I would like to invite you for a cup of coffee. Sincerely yours, Bob.

Example 2:

using namespace templtext;

std::unique_ptr<Templ> tf1( new Templ( "You have got an $decode( 1 )." ) );
std::unique_ptr<Templ> tf2( new Templ( "You have got an $decode( 2 )." ) );
std::unique_ptr<Templ> tf3( new Templ( "English version - $decode_loc( 1, EN )." ) );
std::unique_ptr<Templ> tf4( new Templ( "German version  - $decode_loc( 1, DE )." ) );
std::unique_ptr<Templ> tf5( new Templ( "Flexible version - $decode_loc( 1, %LANG )." ) );

tf1->set_func_proc( func );
tf2->set_func_proc( func );
tf3->set_func_proc( func );
tf4->set_func_proc( func );
tf5->set_func_proc( func );

Templ::MapKeyValue map1 =
{
        { "LANG", "EN" }
};

Templ::MapKeyValue map2 =
{
        { "LANG", "DE" }
};

std::cout << tf1->format() << std::endl;
std::cout << tf2->format() << std::endl;
std::cout << tf3->format() << std::endl;
std::cout << tf4->format() << std::endl;
std::cout << tf5->format( map1 ) << std::endl;
std::cout << tf5->format( map2 ) << std::endl;

Output:

You have got an apple.
You have got an orange.
English version - apple.
German version  - Apfel.
Flexible version - apple.
Flexible version - Apfel.

참고URL : https://stackoverflow.com/questions/355650/c-html-template-framework-templatizing-library-html-generator-library

반응형