play 프레임워크 학습 노트의 템플릿 엔진

3328 단어 htmljqueryjspcss
템플릿 구문
${client.name}
${client?.name} client가 존재하는지 확인할 수 없을 때?
#{extends/}
#{doLayout/}
#{get}
#{set}
예컨대
#{extends 'simpledesign.html'/}
#{set title:'A decorated page'/}
Tags: #{tagName/}
#{script 'jquery.js'/}
#{list items:client.accounts,as:'account'}순환
  • ${account}

  • #{/list}
    Actions: @{…} or @@{…}
    All accounts
    지금 Clients를 참고하십시오.showAccounts(client.id)에 따옴표가 없습니다.
    그러나

    이 다른 공공 자원들은 '/public/stylesheets/main이 필요합니다.css'내부에 인용부호를 붙인 경우 특히 주의하십시오
    @ {...} 상대 경로
    @@ {...} 절대 경로
    Messages: &{…}
    예를 들어 conf/messages 파일에서
    clientName=The client name is %s
    

    템플릿 페이지에서 &{...} 사용
    <h1>&{'clientName','myname' }</h1>
           <h1>The client name is myname</h1>

    Comment: *{…}* 注释

    *{**** Display the user name ****}*

    %{…}% 类似过去的JSP页面一样在页面里嵌入逻辑

    %{ fullName = client.name.toUpperCase()+' '+client.forname; }%

    <h1>Client ${fullName}</h1>

    To create ahellotag, just create theapp/views/tags/hello.htmlfile.

    比如创建一个hello标签,只需要建立页面app/views/tags/hello.html

            Hello from tag!
    

    No need to configure anything. You can use the tag directly:
    다른 것을 설정할 필요가 없습니다. 이 탭을 직접 사용할 수 있습니다
     :   #{hello /}
             
         hello.html       ${_name}   name前面加 _
      
    #{hello name:'Bob' /}       
                    arg

    Example:

    Hello ${_arg}!
    
    And you can call it easily using:
    #{hello 'Bob' /}

            Invoke tag body
    Hello #{doBody /}!

    #{hello}
    Bob
    #{/hello}
        
    #{doBody /}      Bob                 

    기본 템플릿 페이지는views/tags 디렉터리에 있습니다. 폴더를 다시 만들면 다음과 같습니다.
               #{a.xxx /}

    좋은 웹페이지 즐겨찾기