Permalink
Browse files

added method to output JavaScript (via Dan)

  • Loading branch information...
1 parent d2ef868 commit de567f7cd75886ca96f634a828c15bbcb07ad1b8 Terrence Talbot committed Jul 20, 2010
Showing with 27 additions and 0 deletions.
  1. +5 −0 KSHTMLWriter.h
  2. +22 −0 KSHTMLWriter.m
View
@@ -85,6 +85,11 @@
media:(NSString *)media;
+#pragma mark Script
+- (void)writeScriptSrc:(NSString *)src // Note: You should either use src OR contents, not both.
+ orContents:(NSString *)contents // However you can specify contents for comments, which is OK.
+ useCDATA:(BOOL)useCDATA;
+
#pragma mark Style
- (void)startStyleElementWithType:(NSString *)type;
View
@@ -149,6 +149,28 @@ - (void)writeLinkToStylesheet:(NSString *)href
[self writeLinkWithHref:href type:@"text/css" rel:@"stylesheet" title:title media:media];
}
+#pragma mark javascript
+
+- (void)writeScriptSrc:(NSString *)src // Note: You should either use src OR contents, not both.
+ orContents:(NSString *)contents // However you can specify contents for comments, which is OK.
+ useCDATA:(BOOL)useCDATA;
+{
+ [self openTag:@"script"];
+
+ [self writeAttribute:@"type" value:@"text/javascript"];
+ if (src) [self writeAttribute:@"src" value:src];
+ [self didStartElement];
+ if (contents)
+ {
+ // DO NOT USE startNewline since we don't want indentation
+ [self writeString:useCDATA ? @"\n/* <![CDATA[ */\n" : @"\n"];
+ [self writeString:contents];
+ [self writeString:useCDATA ? @"\n/* ]]> */\n" : @"\n"];
+ }
+
+ [self endElement];
+}
+
#pragma mark Style
- (void)startStyleElementWithType:(NSString *)type;

0 comments on commit de567f7

Please sign in to comment.