2012-08-14 3 views
0

EE 템플릿 시스템에서 생성 된 여분의 공백을 제거하고 "더 예쁜"마크 업을 생성하는 방법이 있는지 궁금합니다.ExpressionEngine 템플릿에서 공백 제거

나는 템플릿을 읽을 수있게 유지하려고합니다. 나는 종종 일 년 후에 일자리로 돌아가거나, 다른 개발자의 일을 따르거나, 팀의 일원으로 일해야하며, 모든 것이 깔끔하고 중첩 될 때 더 쉽습니다.

EE는 모든 탭과 줄 바꿈을 유지하며 많은 조건문이있을 때 코드가 엉망이됩니다. 예를 들어,이 :

<div class=" 
    event {if event_all_day}all_day{/if} 
    {if event_multi_day}multi_day{/if} 
    {if event_first_day}first_day{/if} 
    {if event_last_day}last_day{/if} 
    {if all_day_event_index_difference > 0}index_difference_{all_day_event_index_difference}{/if} 
"> 
    {if event_multi_day} 
     <a href="{path='calendar_main/event'}/{event_id}/">{event_title}</a> 
    {if:else} 
     <a href="{path='calendar_main/event'}/{if edited_occurrence}{event_parent_id}{if:else}{event_id}{/if}/" title="{event_title}">{event_title}</a> 
    {/if} 
</div> 

이로 렌더링 :

<div class=" 
             event all_day 
             multi_day 


                       "> 

             <a href="http://www.downtownmuncie.org/calendar_main/event/1832/">Minnetrista Glass Show</a> 
                     </div> 

모든 탭과 EE 태그를 둘러싼 라인 브레이크는 보존됩니다, 그래서 나는 <div> 사이의 공백 마일과 바람 </div>.

성능면에서는 의미가 없습니다. 파일 크기가 커지면 인수가있을 수 있지만 무시해도됩니다. Firebug를 사용하여 코드를 탐색하려고 할 때도 약간의 방해가됩니다.

그러나 무엇보다도, 그것은 단지 엉성한 것처럼 보입니다.

한 가지 제안과 같이, 그에 따라 템플릿을 조정하는 것입니다

정말 실행 가능한 해결책이 아니다
<div class="event {if event_all_day}all_day {/if}{if event_multi_day}multi_day {/if}{if event_first_day}first_day {/if}{if event_last_day}last_day {/if}{if all_day_event_index_difference > 0} index_difference_{all_day_event_index_difference}{/if}"> 
    {if event_multi_day}<a href="{path='calendar_main/event'}/{event_id}/">{event_title}</a>{if:else}<a href="{path='calendar_main/event'}/{if edited_occurrence}{event_parent_id}{if:else}{event_id}{/if}/" title="{event_title}">{event_title}</a>{/if} 
</div> 

. 깔끔한 템플릿과 깔끔한 ​​코드 사이의 선택을 감안할 때, 나는 이전과 같이 가야 할 것입니다.

두 가지 방법이 있습니까?

ty

답변

0

자동 또는 수동 솔루션을 찾고 있는지 잘 모르겠습니다. 나는 자동적 인 것을 전혀 알지 못한다. 그러나 나는 누군가가 더 굉장한 도움을 줄 것이라고 확신한다. 나는 매뉴얼의 팬이므로 FF로 It's All Text을 사용하여이 텍스트 영역과 에디터를 연결하는 EE 템플릿에 "실제"편집기를 사용하십시오. 이 시점에서 철학이 지시하는 템플릿에 공백 규칙을 적용 할 수 있습니다.

0

AutoMin for EE by Jesse Bunch에는 HTML 압축 기능이 있습니다. HTMLTidy와 같은 들여 쓰기를 아름답게 만들지는 않지만 파일 크기를 줄이기 위해 공백을 모두 제거합니다.

0

이것은 테스트되지 않았지만 비슷한 상황 (EE인지 여부는 솔직히 기억할 수 없음)에서 공백을 서버 측 코드 안에 넣었습니다. 따라서 :

<div class="event {if 
    event_all_day}all_day {/if}{if 
    event_multi_day}multi_day {/if}{if 
    event_first_day}first_day {/if}{if 
    event_last_day }last_day {/if}{if 
    all_day_event_index_difference > 0}index_difference_{all_day_event_index_difference{/if} 
"> 
    {if 
     event_multi_day}<a href="{path='calendar_main/event'}/{event_id}/">{event_title}</a> 
    {if:else 
    }<a href="{path='calendar_main/event'}/{if edited_occurrence}{event_parent_id}{if:else 
    }  {event_id}{/if}/" title="{event_title}">{event_title}</a> 
    {/if} 
</div>