TAILIEUCHUNG - Embedding Perl in HTML with Mason Chapter 12: Custom Mason Subclasses- P2

Tham khảo tài liệu 'embedding perl in html with mason chapter 12: custom mason subclasses- p2', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 12 Custom Mason Subclasses- P2 Output Compiling to a Different Output So you ve decided that you really hate Mason and you want to use Embperl instead. But you have a number of Mason components you ve already written that you d like to save. Well you can create your own compiler to generate Embperl code from Mason. In this case we ll use the lexer as is and rewrite the compiler from scratch. There isn t really a one-to-one match between Mason and Embperl s features so this example will like the lexer example be limited in scope. Finding an intelligent way to convert Mason s methods and subcomponents to Embperl is beyond the scope of this book. In case you are unfamiliar with Embperl it uses the following syntax tags contain code whose results should be sent to the browser like Mason s substitution tag . The tags contain Perl code that is not intended to generate output. This is equivalent to Mason s -lines and perl blocks. Finally Embperl also has a tag similar to Mason s once block. There are other Embperl tags but once again this is a simplified example. Embperl does have a feature similar to Mason s inheritance system called EmbperlObject but translating between the two is nontrivial. So let s make our new compiler package HTML Mason Compiler ToEmbperl VERSION use strict use HTML Mason Lexer use HTML Mason Exceptions abbr qw syntax_error use HTML Mason Compiler use base qw HTML Mason Compiler This pulls in the basic packages we ll need. Even though we really aren t inheriting much from HTML Mason Compiler we still subclass it as anything expecting a compiler will check that what it is given is a subclass ofHTML Mason Compiler. Of course in our case we won t be using this compiler with the HTML Mason Interp class so the point is moot but important to mention. sub compile my self p @_ self- lexer- lex comp_source p comp_source name Embperl compiler self return self- component_as_embperl The only parameter we expect is comp_source. We tell the lexer .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.