From ecfabe0bff56d5ac36a9c34950fda457c3740bff Mon Sep 17 00:00:00 2001 From: Mike Abdullah Date: Tue, 27 Jul 2010 21:59:55 +0100 Subject: [PATCH] Expose -className. --- KSHTMLWriter.h | 1 + KSHTMLWriter.m | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/KSHTMLWriter.h b/KSHTMLWriter.h index 0919311..e05ddd9 100644 --- a/KSHTMLWriter.h +++ b/KSHTMLWriter.h @@ -36,6 +36,7 @@ #pragma mark CSS Class Name // Class names are accumulated and written automatically as an attribute of the next element started - (void)addClassName:(NSString *)className; +- (NSString *)className; #pragma mark HTML Fragments diff --git a/KSHTMLWriter.m b/KSHTMLWriter.m index c2ab394..2297736 100644 --- a/KSHTMLWriter.m +++ b/KSHTMLWriter.m @@ -59,6 +59,16 @@ - (void)addClassName:(NSString *)className; [_classNames addObject:className]; } +- (NSString *)className; +{ + NSString *result = nil; + if ([_classNames count]) + { + result = [_classNames componentsJoinedByString:@" "]; + } + return result; +} + #pragma mark HTML Fragments - (void)writeHTMLString:(NSString *)html; @@ -294,9 +304,9 @@ - (BOOL)canWriteElementInline:(NSString *)tagName; - (void)startElement:(NSString *)elementName writeInline:(BOOL)writeInline; // for more control { // Add in any pre-written classes - if ([_classNames count]) + NSString *class = [self className]; + if (class) { - NSString *class = [_classNames componentsJoinedByString:@" "]; [_classNames removeAllObjects]; [self addElementAttribute:@"class" value:class]; }