jhartwell / haml-rs Goto Github PK
View Code? Open in Web Editor NEWA pure Rust implementation of the Haml template language
License: MIT License
A pure Rust implementation of the Haml template language
License: MIT License
There are way too many warnings when compiling. Ideally, there should be none so that needs to be cleaned up.
There needs to be better documentation in the codebase to make it easier to navigate and understand
Currently only the html syntax for attributes is supported but in order to keep up with the standard implementation we should be able to handle Ruby dictionary attributes as well
If you ever come back to this project, I want to note I am starting my own HAML parser and renderer. So far I have only made a new Lexer and have not done the parsing, but it's streamlined and handles both inline and multiline comments so far.
https://github.com/ryankopf/hamlrs
Happy to collaborate for a great, official Rust HAML parser!
The user should be able to get an idea of what the AST will look like when they are converting a Haml file to HTML. This would just show the abstract syntax tree and not actually do the conversion.
Right now the CLI only takes two arguments: input file and output file. There should be an option to allow the user to supply an input folder and destination folder and the files will be converted to HTML with the original file names and just an HTML extension.
While the CLI would not be able to be moved to Web Assembly, we could easily move the library to web assembly which would allow us to utilize haml-rs in the browser.
In order to be useful for future projects I want to work on as well as just keeping up with standard implementation variables need to be supported.
Looks like haml-spec
might be helpful for increasing test coverage. :) I'd be more than happy to take a look at this if you want me to.
When the scanner encounters a \n
it will actually create a newline, however, it is allowing \r
control characters to get through. This is causing issues with Doctypes since the html generation is looking for 5 but is finding 5\r
If I use this test data:
Sentence. Another sentence.
...with the following as my Rust binary:
#! /usr/bin/env run-cargo-script
//! ```cargo
//! [dependencies]
//! hamlrs = "0.4.1"
//! ```
extern crate haml;
use {
haml::to_html as haml_to_html,
std::{
error::Error,
io::{
stdin,
Read,
},
},
};
pub fn main() -> Result<(), Box<Error>> {
let mut input = String::new();
stdin().read_to_string(&mut input)?;
println!("{}", haml_to_html(&input));
Ok(())
}
...then I get this error with RUST_BACKTRACE=1
:
thread 'main' panicked at 'Expecting text value for class name', /home/erich/.cargo/registry/src/github.com-1ecc6299db9ec823/hamlrs-0.4.1/src/parser.rs:90:34
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::print
at libstd/sys_common/backtrace.rs:71
at libstd/sys_common/backtrace.rs:59
2: std::panicking::default_hook::{{closure}}
at libstd/panicking.rs:211
3: std::panicking::default_hook
at libstd/panicking.rs:227
4: std::panicking::rust_panic_with_hook
at libstd/panicking.rs:511
5: std::panicking::begin_panic
6: haml::parser::Parser::parse
7: haml::to_html
8: compile::main
9: std::rt::lang_start::{{closure}}
10: std::panicking::try::do_call
at libstd/rt.rs:59
at libstd/panicking.rs:310
11: __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:105
12: std::rt::lang_start_internal
at libstd/panicking.rs:289
at libstd/panic.rs:392
at libstd/rt.rs:58
13: main
14: __libc_start_main
15: _start
The output of rustup show
is:
active toolchain
----------------
stable-x86_64-unknown-linux-gnu (default)
rustc 1.28.0 (9634041f0 2018-07-30)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.