所以唯一的洼对我来说,实际上这是为了解析Devicons提供的图标列表。
因此,我手动创建了一个列表在辅助方法的数组中,然后在那里做了零检查。
所以它看起来像这样:
def language_icon(language)
devicons = ["amazonwebservices", "android", "angularjs", "apache", "appcelerator", "apple", "atom", "backbonejs",
"bitbucket", "bootstrap", "bower", "c", "chrome", "codeigniter", "coffeescript", "confluence", "cplusplus", "csharp",
"css3", "d3js", "debian", "django", "docker", "doctrine", "dot-net", "drupal", "erlang", "firefox", "foundation", "gimp",
"git", "github", "gitlab", "go", "grunt", "gulp", "heroku", "html5", "ie10", "illustrator", "inkscape", "java", "javascript",
"jeet", "jetbrains", "jquery", "krakenjs", "laravel", "less", "linux", "meteor", "mongodb", "moodle", "mysql", "nginx",
"nodejs", "nodewebkit", "orale", "photoshop", "php", "phpstorm", "postgresql", "python", "rails", "react", "redhat", "redis",
"ruby", "safari", "sass", "sourcetree", "ssh", "symfony", "travis", "trello", "ubuntu", "vim", "windows8", "wordpress", "yii", "zend"]
if devicons.include?(language)
content_tag(:i, "", class: "devicon-#{language}-plain")
else
content_tag(:i, "", class: "fa fa-diamond")
end
end
这就像一个魅力。
我希望这可以帮助别人!
从哪里'question.language'从哪里来? – uzaif
我的本地数据库。我正在使用语法高亮器(Rouge),它为Lexer提供了一个支持的语言库。无论何时用户创建问题,他们都可以从相当广泛的列表中选择一种语言。 – marcamillion
是否在资产中添加了字体? – uzaif