Skip to content

Commit

Permalink
Can now ditch -openTag:writeInline:
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeabdullah committed Jul 27, 2010
1 parent 5136d54 commit c8bc317
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 31 deletions.
4 changes: 2 additions & 2 deletions KSHTMLWriter.m
Expand Up @@ -291,7 +291,7 @@ - (BOOL)canWriteElementInline:(NSString *)tagName;

#pragma mark Element Primitives

- (void)openTag:(NSString *)element writeInline:(BOOL)writeInline;
- (void)startElement:(NSString *)elementName writeInline:(BOOL)writeInline; // for more control
{
// Add in any pre-written classes
if ([_classNames count])
Expand All @@ -301,7 +301,7 @@ - (void)openTag:(NSString *)element writeInline:(BOOL)writeInline;
[self addAttribute:@"class" value:class];
}

[super openTag:element writeInline:writeInline];
[super startElement:elementName writeInline:writeInline];
}

- (void)closeEmptyElementTag; // /> OR > depending on -isXHTML
Expand Down
1 change: 0 additions & 1 deletion KSXMLWriter.h
Expand Up @@ -86,7 +86,6 @@


#pragma mark Element Primitives
- (void)openTag:(NSString *)element writeInline:(BOOL)writeInline;
- (void)closeEmptyElementTag;


Expand Down
53 changes: 25 additions & 28 deletions KSXMLWriter.m
Expand Up @@ -105,7 +105,31 @@ - (void)startElement:(NSString *)elementName;

- (void)startElement:(NSString *)elementName writeInline:(BOOL)writeInline;
{
[self openTag:elementName writeInline:writeInline];
// Can only write suitable tags inline if containing element also allows it
if (!writeInline)
{
[self startNewline];
[self stopWritingInline];
}

elementName = [elementName lowercaseString]; // writes coming from the DOM are uppercase
[self writeString:@"<"];
[self writeString:elementName];

// Must do this AFTER writing the string so subclasses can take early action in a -writeString: override
[self pushElement:elementName];


// Write attributes
for (int i = 0; i < [_attributes count]; i+=2)
{
NSString *attribute = [_attributes objectAtIndex:i];
NSString *value = [_attributes objectAtIndex:i+1];
[self writeAttribute:attribute value:value];
}
[_attributes removeAllObjects];


[self didStartElement];
}

Expand Down Expand Up @@ -252,33 +276,6 @@ - (void)popElement;

#pragma mark Element Primitives

- (void)openTag:(NSString *)element writeInline:(BOOL)writeInline;
{
// Can only write suitable tags inline if containing element also allows it
if (!writeInline)
{
[self startNewline];
[self stopWritingInline];
}

element = [element lowercaseString]; // writes coming from the DOM are uppercase
[self writeString:@"<"];
[self writeString:element];

// Must do this AFTER writing the string so subclasses can take early action in a -writeString: override
[self pushElement:element];


// Write attributes
for (int i = 0; i < [_attributes count]; i+=2)
{
NSString *attribute = [_attributes objectAtIndex:i];
NSString *value = [_attributes objectAtIndex:i+1];
[self writeAttribute:attribute value:value];
}
[_attributes removeAllObjects];
}

- (void)writeAttribute:(NSString *)attribute
value:(NSString *)value;
{
Expand Down

0 comments on commit c8bc317

Please sign in to comment.