tailieunhanh - Embedding Perl in HTML with Mason Chapter 11: Recipes- P3

Tham khảo tài liệu 'embedding perl in html with mason chapter 11: recipes- p3', 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 11 Recipes- P3 With Stylesheets One way to do this is to use stylesheets for all of your pages. Each cobrand will then have a different stylesheet. However since most of the stylesheets will be the same for each client you ll probably want to have a parent stylesheet that all the others inherit from. Of course while it is supposed to be possible to inherit stylesheets some older browsers like Netscape don t support that at all so we will generate the stylesheet on the fly using Mason instead. This gives you all the flexibility of inheritance without the compatibility headaches. The stylesheet will be called via link rel stylesheet href cobrand cobrand Presumably this snippet would go in a top-level The component might look something like Example 11-9. Example 11-9. while my name def each styles name def args cobrand args init my styles die Security violation style style unless cobrand A w foreach my file local FILE open FILE var styles file or die Cannot read var styles file while FILE next unless S s S. x styles 1 2 close FILE r- content_type text css init Of course this assumes that each line of the stylesheet represents a single style definition something like .foo_class color blue This isn t that hard to enforce for a project but it limits you to just a subset of CSS functionality. If this is not desirable check out the CSS and CSS SAC modules on CPAN. This component first grabs all the default styles from the file and then overwrites any styles that are defined in the co-brand-specific file. One nice aspect of this method is that if the site designers are not programmers they can just work with plain old stylesheets which should make them more comfortable. With Code Another way to do this is to store the color preferences for each co-brand in a component or perhaps in the database. At the beginning of each request you could fetch these colors and pass them to each .

TỪ KHÓA LIÊN QUAN